//method to create contractspublic bool Insert_ContractRecords(string contractID, string empName, SqlDateTime startDate, SqlDateTime endDate, float amount, string vendorbrn, string name, string products, string rfpRef, string projectTitle, string alert){SqlCommand cmd_ContractList = new SqlCommand();cmd_ContractList.CommandText = "[VRM].[INSERT_ContractRecords]";cmd_ContractList.CommandType = CommandType.StoredProcedure;cmd_ContractList.Parameters.Clear();SqlParameter sqlParaContractID = new SqlParameter("@contractID", SqlDbType.VarChar, 10);//ContractIDsqlParaContractID.Value = contractID;cmd_ContractList.Parameters.Add(sqlParaContractID);SqlParameter sqlParaEmpName = new SqlParameter("@empName", SqlDbType.VarChar, 140);//Owner Name aka Employee NamesqlParaEmpName.Value = formatWildCard(empName);cmd_ContractList.Parameters.Add(sqlParaEmpName);SqlParameter sqlParaStartDate = new SqlParameter("@startDate", SqlDbType.DateTime); //Contract Start DATEsqlParaStartDate.Value = startDate;cmd_ContractList.Parameters.Add(sqlParaStartDate);SqlParameter sqlParaEndDate = new SqlParameter("@endDate", SqlDbType.DateTime); //Contract End datesqlParaEndDate.Value = endDate;cmd_ContractList.Parameters.Add(sqlParaEndDate);SqlParameter sqlParaAmount = new SqlParameter("@amount", SqlDbType.Float); //amountsqlParaAmount.Value = amount;cmd_ContractList.Parameters.Add(sqlParaAmount);SqlParameter sqlParaVendorBRN = new SqlParameter("@vendorbrn", SqlDbType.VarChar, 10);//Vendor BRNsqlParaVendorBRN.Value = vendorbrn;cmd_ContractList.Parameters.Add(sqlParaVendorBRN);SqlParameter sqlParaVendorName = new SqlParameter("@name", SqlDbType.VarChar, 140);//Vendor NamesqlParaVendorName.Value = name;cmd_ContractList.Parameters.Add(sqlParaVendorName);SqlParameter sqlParaProducts = new SqlParameter("@products", SqlDbType.VarChar, 1000);//Products/Services provided by vendorsqlParaProducts.Value = products;cmd_ContractList.Parameters.Add(sqlParaProducts);SqlParameter sqlParaRFPRef = new SqlParameter("@rfpRef", SqlDbType.VarChar, 50);//RFPRefsqlParaRFPRef.Value = rfpRef;cmd_ContractList.Parameters.Add(sqlParaRFPRef);SqlParameter sqlParaProjectTitle = new SqlParameter("@projectTitle", SqlDbType.VarChar, 50);//Project TitlesqlParaProjectTitle.Value = projectTitle;cmd_ContractList.Parameters.Add(sqlParaProjectTitle);SqlParameter sqlParaAlert = new SqlParameter("@alert", SqlDbType.VarChar, 1);//AlertsqlParaAlert.Value = alert;cmd_ContractList.Parameters.Add(sqlParaAlert);return executeNotQuery(cmd_ContractList);}
ALTER PROCEDURE [VRM].[INSERT_ContractRecords](@contractID varchar(10), @empName varchar(140),@startDate datetime,@endDate datetime,@amount float,@vendorbrn varchar(10), @name varchar(140), @products varchar(1000), @rfpRef varchar(50), @projectTitle varchar(50), @alert varchar(1), @templateID varchar(10))ASBEGININSERT INTO VRM.ContractManagement VALUES( @contractID , @empName,@startDate, @endDate,@amount,@vendorbrn,@name,@products,@rfpRef,@projectTitle,@alert,@templateID)END
protected void gvContract_RowCommand(object sender, GridViewCommandEventArgs e){if (e.CommandName.Equals("AddNew")){TextBox txtContractID = (TextBox)gvContract.FooterRow.FindControl("txtContractID");TextBox txtEmpName = (TextBox)gvContract.FooterRow.FindControl("ttxtEmpName");TextBox txtStartDate = (TextBox)gvContract.FooterRow.FindControl("txtstartDate");TextBox txtEndDate = (TextBox)gvContract.FooterRow.FindControl("txtEndDate");TextBox txtAmount = (TextBox)gvContract.FooterRow.FindControl("txtEndDate");TextBox txtVendorBRN = (TextBox)gvContract.FooterRow.FindControl("txtVendorBRN");TextBox txtName = (TextBox)gvContract.FooterRow.FindControl("txtName ");TextBox txtProducts = (TextBox)gvContract.FooterRow.FindControl("txtProducts ");TextBox txtRef = (TextBox)gvContract.FooterRow.FindControl("txtRef");TextBox txtProj = (TextBox)gvContract.FooterRow.FindControl("txtProj");TextBox txtAlert = (TextBox)gvContract.FooterRow.FindControl("txtProj");vrmdb.Insert_ContractRecords(txtContractID.Text, txtEmpName.Text, txtStartDate.Text, txtEndDate.Text, txtAmount.Text, txtVendorBRN.Text, txtName.Text, txtProducts.Text, txtRef.Text, txtProj.Text, txtAlert.Text);BindGrid(true);Response.Redirect("ContractThreeGridView.aspx");}}