public ReportUI(SalesUI frmSales) { InitializeComponent(); ds = new BizCareDataSet(); rpt = new ReportDocument(); reportRepository = new ReportRepository(); this.frmSales = frmSales; }
/***********************************Function to Save Sales File into Sql Server 2000 using Bulk Copy Method***********************************/ public string SaveSales(DataTable dt) { string lblMessage = ""; SalesController objCont = new SalesController(); string sConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString(); //try //{ // string strDelete = "Delete from SalesTemp"; // objController.ExecuteQuery(strDelete); // SqlConnection sqlconn = new SqlConnection(sConnectionString); // sqlconn.Open(); // SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlconn); // bulkCopy.DestinationTableName = "SalesTemp"; // bulkCopy.WriteToServer(dt); //} //catch //{ //} DataTable dtMonthOC = new DataTable(); string strMonthOCQuery = "select * from MonthOpenClose"; dtMonthOC = objController.ExecuteQuery(strMonthOCQuery); DataView dvMonthOC = new DataView(dtMonthOC); DataTable dtFilter = new DataTable(); string[] strFromSalesMonth = txtSalesFromDate.Text.Trim().Split('/'); int FromMonth = Convert.ToInt16(strFromSalesMonth[1]); //int FromMonth = CalSalesfromDate.SelectedDate.Month; dvMonthOC.RowFilter = "MonthID =" + FromMonth; dtFilter = dvMonthOC.ToTable(); if (dtFilter.Rows != null) { bool OCStatus = Convert.ToBoolean(dtFilter.Rows[0]["Status"]); if (OCStatus == false) { lblMessage = "Month is Closed, Please open month to enter data"; } else { string[] strToSalesDate = txtSalesToDate.Text.Trim().Split('/'); //int ToMonth = CalSalestoDate.SelectedDate.Month; int ToMonth = Convert.ToInt16(strToSalesDate[1]); int rcount = 0; foreach (DataRow dr in dt.Rows) { int IsModelEx = 1; SalesUI objUI = new SalesUI(); try { objUI.Sno = Convert.ToInt32(dr["Sno"]); if (dr["Inv#No"].ToString() == "7253102") { string strTest = ""; } objUI.InvoiceNo = Convert.ToInt32(dr["Inv#No"]); //objUI.Date = Convert.ToString(dr["Date"]); string strDate = Convert.ToString(dr["Date"]); if (strDate == "" || strDate == "00.00.0000") { objUI.Date = Convert.ToDateTime("1/1/2001"); } else { objUI.Date = Convert.ToDateTime(ConvertDateTime(Convert.ToString(dr["Date"]))); } objUI.Dealer_Code = Convert.ToString(dr["DlrCode"]); objUI.Dealer_Name = Convert.ToString(dr["Dlr Name"]); objUI.Blank = Convert.ToString(dr["F10"]); string strMaterial = dr["F10"].ToString(); string strModelQuery = "Select * from ModelMapping where Material='" + strMaterial + "'"; DataTable dtModel = objController.ExecuteQuery(strModelQuery); if (dtModel != null) { if (dtModel.Rows.Count > 0) { foreach (DataRow drModel in dtModel.Rows) { objUI.ModelMappingID = Convert.ToInt32(drModel["ID"].ToString()); IsModelEx = 0; } } } objUI.Model_Code = Convert.ToString(dr["Model Code"]); string strQuantity = Convert.ToString(dr["Qty"]); if (strQuantity == "") { objUI.Quantity = Convert.ToInt32(null); } else { objUI.Quantity = Convert.ToInt32(dr["Qty"]); } string strSaleAmt = dr["Sale Amt"].ToString(); if (strSaleAmt == "") { objUI.SalesAmount = Convert.ToDouble(null); } else { objUI.SalesAmount = Convert.ToDouble(dr["Sale Amt"]); } string strDiscount = Convert.ToString(dr["Discount"]); if (strDiscount == "") { objUI.Discount = Convert.ToInt32(null); } else { objUI.Discount = Convert.ToInt32(dr["Discount"]); } string strSPLDIS = Convert.ToString(dr["SPL#DIS"]); if (strSPLDIS == "") { objUI.SPLDIS = Convert.ToDouble(null); } else { objUI.SPLDIS = Convert.ToDouble(dr["SPL#DIS"]); } string strExciseDuty = Convert.ToString(dr["Excise Duty"]); if (strExciseDuty == "") { objUI.ExciseDuty = Convert.ToInt32(null); } else { objUI.ExciseDuty = Convert.ToInt32(dr["Excise Duty"]); } //objUI.Edu_Cess = Convert.ToInt32(dr["Edu# Cess"]); //objUI.HR_ECess = Convert.ToInt32(dr["Hr#ECess"]); string strEdu_Cess = Convert.ToString(dr["Edu# Cess"]); if (strEdu_Cess == "") { objUI.Edu_Cess = Convert.ToInt32(null); } else { objUI.Edu_Cess = Convert.ToInt32(dr["Edu# Cess"]); } string strHRECess = Convert.ToString(dr["Hr#ECess"]); if (strHRECess == "") { objUI.HR_ECess = Convert.ToInt32(null); } else { objUI.HR_ECess = Convert.ToInt32(dr["Hr#ECess"]); } string strLSPD = Convert.ToString(dr["LSPD"]); if (strLSPD == "") { objUI.LSPD = Convert.ToInt32(null); } else { objUI.LSPD = Convert.ToInt32(dr["LSPD"]); } string strMSPSD = Convert.ToString(dr["MSPSD"]); if (strMSPSD == "") { objUI.MSPSD = Convert.ToInt32(null); } else { objUI.MSPSD = Convert.ToInt32(dr["MSPSD"]); } string strDHC = Convert.ToString(dr["DHC"]); if (strDHC == "") { objUI.DHC = Convert.ToInt32(null); } else { objUI.DHC = Convert.ToInt32(dr["DHC"]); } string strTaxable = Convert.ToString(dr["Taxable"]); if (strTaxable == "") { objUI.Taxable = Convert.ToDouble(null); } else { objUI.Taxable = Convert.ToDouble(dr["Taxable"]); } string strCST = Convert.ToString(dr["CST"]); if (strCST == "") { objUI.CST = Convert.ToDouble(null); } else { objUI.CST = Convert.ToDouble(dr["CST"]); } string strLST = Convert.ToString(dr["LST"]); if (strLST == "") { objUI.LST = Convert.ToDouble(null); } else { objUI.LST = Convert.ToDouble(dr["LST"]); } string strSurch = Convert.ToString(dr["Surch"]); if (strSurch == "") { objUI.Surch = Convert.ToInt32(null); } else { objUI.Surch = Convert.ToInt32(dr["Surch"]); } string strDely_Chgs = Convert.ToString(dr["Dely Chgs"]); if (strDely_Chgs == "") { objUI.Dely_Chgs = Convert.ToInt32(null); } else { objUI.Dely_Chgs = Convert.ToInt32(dr["Dely Chgs"]); } string strEntityTot = Convert.ToString(dr["Enty/TOT"]); if (strEntityTot == "") { objUI.EntityTot = Convert.ToDouble(null); } else { objUI.EntityTot = Convert.ToDouble(dr["Enty/TOT"]); } string strFreight = Convert.ToString(dr["Freight"]); if (strFreight == "") { objUI.Freight = Convert.ToDouble(null); } else { objUI.Freight = Convert.ToDouble(dr["Freight"]); } string strNetAmount = Convert.ToString(dr["Net Amount"]); if (strNetAmount == "") { objUI.Net_Amount = Convert.ToDouble(null); } else { objUI.Net_Amount = Convert.ToDouble(dr["Net Amount"]); } string strCost = Convert.ToString(dr["Cost"]); if (strCost == "") { objUI.Cost = Convert.ToInt32(null); } else { objUI.Cost = Convert.ToInt32(dr["Cost"]); } objUI.SOff = Convert.ToString(dr["S#Off"]); //objUI.FromDate = CalSalesfromDate.SelectedDate; //objUI.ToDate = CalSalestoDate.SelectedDate; objUI.FromDate = Convert.ToDateTime(objUtility.ConvertDateTime(txtSalesFromDate.Text.Trim())); objUI.ToDate = Convert.ToDateTime(objUtility.ConvertDateTime(txtSalesToDate.Text.Trim())); if (IsModelEx == 0) { objCont.SaveSales(objUI); rcount++; } else { string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[IsApproved],[FromDate],[ToDate],IsModelEx) "; strQuery += "Values ('" + dr["Sno"].ToString() + "','" + dr["Inv#No"].ToString() + "','" + dr["Date"].ToString() + "','" + dr["DlrCode"].ToString() + "','" + dr["Dlr Name"].ToString() + "','" + dr["F10"].ToString() + "','" + dr["Model Code"].ToString() + "','" + dr["Qty"].ToString() + "','" + dr["Sale Amt"].ToString() + "','" + dr["Discount"].ToString() + "','" + dr["SPL#DIS"].ToString() + "','" + dr["Excise Duty"].ToString() + "','" + dr["Edu# Cess"].ToString() + "','" + dr["Hr#ECess"].ToString() + "','" + dr["LSPD"].ToString() + "','" + dr["MSPSD"].ToString() + "','" + dr["DHC"].ToString() + "','" + dr["Taxable"].ToString() + "','" + dr["CST"].ToString() + "','" + dr["LST"].ToString() + "','" + dr["Surch"].ToString() + "','" + dr["Enty/TOT"].ToString() + "','" + dr["Dely Chgs"].ToString() + "','" + dr["Freight"].ToString() + "','" + dr["Net Amount"].ToString() + "','" + dr["Cost"].ToString() + "','" + dr["S#off"] + "',0,'" + objUtility.ConvertDateTime(txtSalesFromDate.Text.Trim()) + "','" + objUtility.ConvertDateTime(txtSalesToDate.Text.Trim()) + "'," + IsModelEx + ")"; objController.ExecuteQuery(strQuery); } lblMessage = "File Sales saved successfully;No of Rows Affected:" + rcount; } catch { lnkSalesException.Visible = true; string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[IsApproved],[FromDate],[ToDate],IsModelEx) "; strQuery += "Values ('" + dr["Sno"].ToString() + "','" + dr["Inv#No"].ToString() + "','" + dr["Date"].ToString() + "','" + dr["DlrCode"].ToString() + "','" + dr["Dlr Name"].ToString() + "','" + dr["F10"].ToString() + "','" + dr["Model Code"].ToString() + "','" + dr["Qty"].ToString() + "','" + dr["Sale Amt"].ToString() + "','" + dr["Discount"].ToString() + "','" + dr["SPL#DIS"].ToString() + "','" + dr["Excise Duty"].ToString() + "','" + dr["Edu# Cess"].ToString() + "','" + dr["Hr#ECess"].ToString() + "','" + dr["LSPD"].ToString() + "','" + dr["MSPSD"].ToString() + "','" + dr["DHC"].ToString() + "','" + dr["Taxable"].ToString() + "','" + dr["CST"].ToString() + "','" + dr["LST"].ToString() + "','" + dr["Surch"].ToString() + "','" + dr["Enty/TOT"].ToString() + "','" + dr["Dely Chgs"].ToString() + "','" + dr["Freight"].ToString() + "','" + dr["Net Amount"].ToString() + "','" + dr["Cost"].ToString() + "','" + dr["S#off"] + "',0,'" + objUtility.ConvertDateTime(txtSalesFromDate.Text.Trim()) + "','" + objUtility.ConvertDateTime(txtSalesToDate.Text.Trim()) + "'," + IsModelEx + ")"; objController.ExecuteQuery(strQuery); } } } } return lblMessage; }
public string SaveSales(DataTable dt) { string lblMessage = ""; SalesController objCont = new SalesController(); string sConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString(); int rcount = 0; foreach (DataRow dr in dt.Rows) { int IsModelEx = 1; int SalesID = Convert.ToInt32(dr["ID"].ToString()); SalesUI objUI = new SalesUI(); try { objUI.Sno = Convert.ToInt32(dr["Sno"]); objUI.InvoiceNo = Convert.ToInt32(dr["Inv#No"]); string strDate = Convert.ToString(dr["Date"]); if (strDate == "" || strDate == "00.00.0000") { objUI.Date = Convert.ToDateTime("1/1/2001"); } else { objUI.Date = Convert.ToDateTime(ConvertDateTime(Convert.ToString(dr["Date"]))); } objUI.Dealer_Code = Convert.ToString(dr["DlrCode"]); objUI.Dealer_Name = Convert.ToString(dr["Dlr Name"]); objUI.Blank = Convert.ToString(dr["F10"]); string strMaterial = dr["F10"].ToString(); string strModelQuery = "Select * from ModelMapping where Material='" + strMaterial + "'"; DataTable dtModel = objQueryController.ExecuteQuery(strModelQuery); if (dtModel != null) { if (dtModel.Rows.Count > 0) { foreach (DataRow drModel in dtModel.Rows) { objUI.ModelMappingID = Convert.ToInt32(drModel["ID"].ToString()); IsModelEx = 0; } } } objUI.Model_Code = Convert.ToString(dr["Model Code"]); objUI.Quantity = Convert.ToInt32(dr["Qty"]); objUI.SalesAmount = Convert.ToDouble(dr["Sale Amt"]); string strDiscount = Convert.ToString(dr["Discount"]); if (strDiscount == "") { objUI.Discount = Convert.ToInt32(null); } else { objUI.Discount = Convert.ToInt32(dr["Discount"]); } string strSPLDIS = Convert.ToString(dr["SPL#DIS"]); if (strSPLDIS == "") { objUI.SPLDIS = Convert.ToDouble(null); } else { objUI.SPLDIS = Convert.ToDouble(dr["SPL#DIS"]); } string strExciseDuty = Convert.ToString(dr["Excise Duty"]); if (strExciseDuty == "") { objUI.ExciseDuty = Convert.ToInt32(null); } else { objUI.ExciseDuty = Convert.ToInt32(dr["Excise Duty"]); } objUI.Edu_Cess = Convert.ToInt32(dr["Edu# Cess"]); objUI.HR_ECess = Convert.ToInt32(dr["Hr#ECess"]); string strLSPD = Convert.ToString(dr["LSPD"]); if (strLSPD == "") { objUI.LSPD = Convert.ToInt32(null); } else { objUI.LSPD = Convert.ToInt32(dr["LSPD"]); } string strMSPSD = Convert.ToString(dr["MSPSD"]); if (strMSPSD == "") { objUI.MSPSD = Convert.ToInt32(null); } else { objUI.MSPSD = Convert.ToInt32(dr["MSPSD"]); } string strDHC = Convert.ToString(dr["DHC"]); if (strDHC == "") { objUI.DHC = Convert.ToInt32(null); } else { objUI.DHC = Convert.ToInt32(dr["DHC"]); } string strTaxable = Convert.ToString(dr["Taxable"]); if (strTaxable == "") { objUI.Taxable = Convert.ToDouble(null); } else { objUI.Taxable = Convert.ToDouble(dr["Taxable"]); } string strCST = Convert.ToString(dr["CST"]); if (strCST == "") { objUI.CST = Convert.ToDouble(null); } else { objUI.CST = Convert.ToDouble(dr["CST"]); } string strLST = Convert.ToString(dr["LST"]); if (strLST == "") { objUI.LST = Convert.ToDouble(null); } else { objUI.LST = Convert.ToDouble(dr["LST"]); } string strSurch = Convert.ToString(dr["Surch"]); if (strSurch == "") { objUI.Surch = Convert.ToInt32(null); } else { objUI.Surch = Convert.ToInt32(dr["Surch"]); } string strDely_Chgs = Convert.ToString(dr["Dely Chgs"]); if (strDely_Chgs == "") { objUI.Dely_Chgs = Convert.ToInt32(null); } else { objUI.Dely_Chgs = Convert.ToInt32(dr["Dely Chgs"]); } string strEntityTot = Convert.ToString(dr["Enty/TOT"]); if (strEntityTot == "") { objUI.EntityTot = Convert.ToInt32(null); } else { objUI.EntityTot = Convert.ToInt32(dr["Enty/TOT"]); } string strFreight = Convert.ToString(dr["Freight"]); if (strFreight == "") { objUI.Freight = Convert.ToDouble(null); } else { objUI.Freight = Convert.ToDouble(dr["Freight"]); } objUI.Net_Amount = Convert.ToDouble(dr["Net Amount"]); objUI.Cost = Convert.ToInt32(dr["Cost"]); objUI.SOff = Convert.ToString(dr["S#Off"]); objUI.FromDate = Convert.ToDateTime(dr["FromDate"].ToString()); objUI.ToDate = Convert.ToDateTime(dr["ToDate"].ToString()); if (IsModelEx == 0) { objCont.SaveSales(objUI); rcount++; } else { string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[IsApproved],[FromDate],[ToDate],IsModelEx) "; strQuery += "Values ('" + dr["Sno"].ToString() + "','" + dr["Inv#No"].ToString() + "','" + dr["Date"].ToString() + "','" + dr["DlrCode"].ToString() + "','" + dr["Dlr Name"].ToString() + "','" + dr["F10"].ToString() + "','" + dr["Model Code"].ToString() + "','" + dr["Qty"].ToString() + "','" + dr["Sale Amt"].ToString() + "','" + dr["Discount"].ToString() + "','" + dr["SPL#DIS"].ToString() + "','" + dr["Excise Duty"].ToString() + "','" + dr["Edu# Cess"].ToString() + "','" + dr["Hr#ECess"].ToString() + "','" + dr["LSPD"].ToString() + "','" + dr["MSPSD"].ToString() + "','" + dr["DHC"].ToString() + "','" + dr["Taxable"].ToString() + "','" + dr["CST"].ToString() + "','" + dr["LST"].ToString() + "','" + dr["Surch"].ToString() + "','" + dr["Enty/TOT"].ToString() + "','" + dr["Dely Chgs"].ToString() + "','" + dr["Freight"].ToString() + "','" + dr["Net Amount"].ToString() + "','" + dr["Cost"].ToString() + "','" + dr["S#off"] + "',0,'" + dr["FromDate"].ToString() + "','" + dr["ToDate"].ToString() + "'," + IsModelEx + ")"; objQueryController.ExecuteQuery(strQuery); } lblMessage = "File Sales saved successfully;No of Rows Affected:" + rcount; } catch { string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[IsApproved],[FromDate],[ToDate],IsModelEx) "; strQuery += "Values ('" + dr["Sno"].ToString() + "','" + dr["Inv#No"].ToString() + "','" + dr["Date"].ToString() + "','" + dr["DlrCode"].ToString() + "','" + dr["Dlr Name"].ToString() + "','" + dr["F10"].ToString() + "','" + dr["Model Code"].ToString() + "','" + dr["Qty"].ToString() + "','" + dr["Sale Amt"].ToString() + "','" + dr["Discount"].ToString() + "','" + dr["SPL#DIS"].ToString() + "','" + dr["Excise Duty"].ToString() + "','" + dr["Edu# Cess"].ToString() + "','" + dr["Hr#ECess"].ToString() + "','" + dr["LSPD"].ToString() + "','" + dr["MSPSD"].ToString() + "','" + dr["DHC"].ToString() + "','" + dr["Taxable"].ToString() + "','" + dr["CST"].ToString() + "','" + dr["LST"].ToString() + "','" + dr["Surch"].ToString() + "','" + dr["Enty/TOT"].ToString() + "','" + dr["Dely Chgs"].ToString() + "','" + dr["Freight"].ToString() + "','" + dr["Net Amount"].ToString() + "','" + dr["Cost"].ToString() + "','" + dr["S#off"] + "',0,'" + dr["FromDate"].ToString() + "','" + dr["ToDate"].ToString() + "'," + IsModelEx + ")"; objQueryController.ExecuteQuery(strQuery); } string strDeleteQuery = "Delete from SalesTemp where [ID]=" + SalesID; objQueryController.ExecuteQuery(strDeleteQuery); } return lblMessage; }
protected void btnUpdate_Click(object sender, EventArgs e) { SalesController objCont = new SalesController(); int rcount = 0; foreach (GridViewRow gr in grdSalesException.Rows) { bool Discard = ((CheckBox)gr.FindControl("chkDiscard")).Checked; string str = ((HiddenField)gr.FindControl("hdnID")).Value; if (Discard == true) { string strDiscardQuery = "Delete from SalesTemp where ID=" + Convert.ToInt16(str); objQueryController.ExecuteQuery(strDiscardQuery); string strQuery = "Select * from SalesTemp"; DataTable dt = new DataTable(); dt = objQueryController.ExecuteQuery(strQuery); grdSalesException.DataSource = dt; grdSalesException.DataBind(); } else { SalesUI objUI = new SalesUI(); try { objUI.Sno = Convert.ToInt16(((TextBox)gr.FindControl("txtSno")).Text); objUI.InvoiceNo = Convert.ToInt32(((TextBox)gr.FindControl("txtInvoiceNo")).Text); //objUI.Date = Convert.ToString(((TextBox)gr.FindControl("txtDate")).Text); string strDate = Convert.ToString(((TextBox)gr.FindControl("txtDate")).Text); if (strDate == "" || strDate == "00.00.0000") { objUI.Date = Convert.ToDateTime("1/1/2001"); } else { objUI.Date = Convert.ToDateTime(ConvertDateTime(((TextBox)gr.FindControl("txtDate")).Text)); } objUI.Dealer_Code = Convert.ToString(((TextBox)gr.FindControl("txtDealerCode")).Text); objUI.Dealer_Name = Convert.ToString(((TextBox)gr.FindControl("txtDealerName")).Text); objUI.Blank = Convert.ToString(((TextBox)gr.FindControl("txtBlank")).Text); string strMaterial = Convert.ToString(((TextBox)gr.FindControl("txtBlank")).Text); objUI.Model_Code = Convert.ToString(((TextBox)gr.FindControl("txtModelCode")).Text); objUI.Quantity = Convert.ToInt16(((TextBox)gr.FindControl("txtQuantity")).Text); objUI.SalesAmount = Convert.ToDouble(((TextBox)gr.FindControl("txtSalesAmt")).Text); string strDiscount = Convert.ToString(((TextBox)gr.FindControl("txtDiscount")).Text); if (strDiscount == "") { objUI.Discount = Convert.ToInt32(null); } else { objUI.Discount = Convert.ToInt32(((TextBox)gr.FindControl("txtDiscount")).Text); } string strSPLDIS = Convert.ToString(((TextBox)gr.FindControl("txtSPLDIS")).Text); if (strSPLDIS == "") { objUI.SPLDIS = Convert.ToDouble(null); } else { objUI.SPLDIS = Convert.ToDouble(((TextBox)gr.FindControl("txtSPLDIS")).Text); } string strExciseDuty = Convert.ToString(((TextBox)gr.FindControl("txtExciseDuty")).Text); if (strExciseDuty == "") { objUI.ExciseDuty = Convert.ToInt16(null); } else { objUI.ExciseDuty = Convert.ToInt16(((TextBox)gr.FindControl("txtExciseDuty")).Text); } objUI.Edu_Cess = Convert.ToInt16(((TextBox)gr.FindControl("txtEduCess")).Text); objUI.HR_ECess = Convert.ToInt16(((TextBox)gr.FindControl("txtHrECess")).Text); string strLSPD = Convert.ToString(((TextBox)gr.FindControl("txtLSPD")).Text); if (strLSPD == "") { objUI.LSPD = Convert.ToInt16(null); } else { objUI.LSPD = Convert.ToInt16(((TextBox)gr.FindControl("txtLSPD")).Text); } string strMSPSD = Convert.ToString(((TextBox)gr.FindControl("txtMSPSD")).Text); if (strMSPSD == "") { objUI.MSPSD = Convert.ToInt16(null); } else { objUI.MSPSD = Convert.ToInt16(((TextBox)gr.FindControl("txtMSPSD")).Text); } string strDHC = Convert.ToString(((TextBox)gr.FindControl("txtDHC")).Text); if (strDHC == "") { objUI.DHC = Convert.ToInt16(null); } else { objUI.DHC = Convert.ToInt16(((TextBox)gr.FindControl("txtDHC")).Text); } string strTaxable = Convert.ToString(((TextBox)gr.FindControl("txtTaxable")).Text); if (strTaxable == "") { objUI.Taxable = Convert.ToDouble(null); } else { objUI.Taxable = Convert.ToDouble(((TextBox)gr.FindControl("txtTaxable")).Text); } string strCST = Convert.ToString(((TextBox)gr.FindControl("txtCST")).Text); if (strCST == "") { objUI.CST = Convert.ToDouble(null); } else { objUI.CST = Convert.ToDouble(((TextBox)gr.FindControl("txtCST")).Text); } string strLST = Convert.ToString(((TextBox)gr.FindControl("txtLST")).Text); if (strLST == "") { objUI.LST = Convert.ToDouble(null); } else { objUI.LST = Convert.ToDouble(((TextBox)gr.FindControl("txtLST")).Text); } string strSurch = Convert.ToString(((TextBox)gr.FindControl("txtSurch")).Text); if (strSurch == "") { objUI.Surch = Convert.ToInt16(null); } else { objUI.Surch = Convert.ToInt16(((TextBox)gr.FindControl("txtSurch")).Text); } string strDely_Chgs = Convert.ToString(((TextBox)gr.FindControl("txtDelyChgs")).Text); if (strDely_Chgs == "") { objUI.Dely_Chgs = Convert.ToInt16(null); } else { objUI.Dely_Chgs = Convert.ToInt16(((TextBox)gr.FindControl("txtDelyChgs")).Text); } string strEntityTot = Convert.ToString(((TextBox)gr.FindControl("txtEntityTot")).Text); if (strEntityTot == "") { objUI.EntityTot = Convert.ToInt16(null); } else { objUI.EntityTot = Convert.ToInt16(((TextBox)gr.FindControl("txtEntityTot")).Text); } string strFreight = Convert.ToString(((TextBox)gr.FindControl("txtFreight")).Text); if (strFreight == "") { objUI.Freight = Convert.ToDouble(null); } else { objUI.Freight = Convert.ToDouble(((TextBox)gr.FindControl("txtFreight")).Text); } objUI.Net_Amount = Convert.ToDouble(((TextBox)gr.FindControl("txtNetAmt")).Text); objUI.Cost = Convert.ToInt16(((TextBox)gr.FindControl("txtCost")).Text); objUI.SOff = Convert.ToString(((TextBox)gr.FindControl("txtSOff")).Text); objUI.FromDate = Convert.ToDateTime(gr.Cells[27].Text); objUI.ToDate = Convert.ToDateTime(gr.Cells[28].Text); string strModelQuery = "Select * from ModelMapping where Material='" + strMaterial + "'"; DataTable dtModel = objQueryController.ExecuteQuery(strModelQuery); if (dtModel != null) { if (dtModel.Rows.Count > 0) { foreach (DataRow drModel in dtModel.Rows) { objUI.ModelMappingID = Convert.ToInt32(drModel["ID"].ToString()); } objCont.SaveSales(objUI); rcount++; } else { string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[FromDate],[ToDate])"; strQuery += "Values ('" + ((TextBox)gr.FindControl("txtSno")).Text + "','" + ((TextBox)gr.FindControl("txtInvoiceNo")).Text + "','" + ((TextBox)gr.FindControl("txtDate")).Text + "','" + ((TextBox)gr.FindControl("txtDealerCode")).Text + "','" + ((TextBox)gr.FindControl("txtDealerName")).Text + "','" + ((TextBox)gr.FindControl("txtBlank")).Text + "','" + ((TextBox)gr.FindControl("txtModelCode")).Text + "','" + ((TextBox)gr.FindControl("txtQuantity")).Text + "','" + ((TextBox)gr.FindControl("txtSalesAmt")).Text + "','" + ((TextBox)gr.FindControl("txtDiscount")).Text + "','" + ((TextBox)gr.FindControl("txtSPLDIS")).Text + "','" + ((TextBox)gr.FindControl("txtExciseDuty")).Text + "','" + ((TextBox)gr.FindControl("txtEduCess")).Text + "','" + ((TextBox)gr.FindControl("txtHrECess")).Text + "','" + ((TextBox)gr.FindControl("txtLSPD")).Text + "','" + ((TextBox)gr.FindControl("txtMSPSD")).Text + "','" + ((TextBox)gr.FindControl("txtDHC")).Text + "','" + ((TextBox)gr.FindControl("txtTaxable")).Text + "','" + ((TextBox)gr.FindControl("txtCST")).Text + "','" + ((TextBox)gr.FindControl("txtLST")).Text + "','" + ((TextBox)gr.FindControl("txtSurch")).Text + "','" + ((TextBox)gr.FindControl("txtEntityTot")).Text + "','" + ((TextBox)gr.FindControl("txtDelyChgs")).Text + "','" + ((TextBox)gr.FindControl("txtFreight")).Text + "','" + ((TextBox)gr.FindControl("txtNetAmt")).Text + "','" + ((TextBox)gr.FindControl("txtCost")).Text + "','" + ((TextBox)gr.FindControl("txtSOff")).Text + "','" + Convert.ToDateTime(gr.Cells[27].Text) + "','" + Convert.ToDateTime(gr.Cells[28].Text) + "')"; objQueryController.ExecuteQuery(strQuery); } } else { string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[FromDate],[ToDate])"; strQuery += "Values ('" + ((TextBox)gr.FindControl("txtSno")).Text + "','" + ((TextBox)gr.FindControl("txtInvoiceNo")).Text + "','" + ((TextBox)gr.FindControl("txtDate")).Text + "','" + ((TextBox)gr.FindControl("txtDealerCode")).Text + "','" + ((TextBox)gr.FindControl("txtDealerName")).Text + "','" + ((TextBox)gr.FindControl("txtBlank")).Text + "','" + ((TextBox)gr.FindControl("txtModelCode")).Text + "','" + ((TextBox)gr.FindControl("txtQuantity")).Text + "','" + ((TextBox)gr.FindControl("txtSalesAmt")).Text + "','" + ((TextBox)gr.FindControl("txtDiscount")).Text + "','" + ((TextBox)gr.FindControl("txtSPLDIS")).Text + "','" + ((TextBox)gr.FindControl("txtExciseDuty")).Text + "','" + ((TextBox)gr.FindControl("txtEduCess")).Text + "','" + ((TextBox)gr.FindControl("txtHrECess")).Text + "','" + ((TextBox)gr.FindControl("txtLSPD")).Text + "','" + ((TextBox)gr.FindControl("txtMSPSD")).Text + "','" + ((TextBox)gr.FindControl("txtDHC")).Text + "','" + ((TextBox)gr.FindControl("txtTaxable")).Text + "','" + ((TextBox)gr.FindControl("txtCST")).Text + "','" + ((TextBox)gr.FindControl("txtLST")).Text + "','" + ((TextBox)gr.FindControl("txtSurch")).Text + "','" + ((TextBox)gr.FindControl("txtEntityTot")).Text + "','" + ((TextBox)gr.FindControl("txtDelyChgs")).Text + "','" + ((TextBox)gr.FindControl("txtFreight")).Text + "','" + ((TextBox)gr.FindControl("txtNetAmt")).Text + "','" + ((TextBox)gr.FindControl("txtCost")).Text + "','" + ((TextBox)gr.FindControl("txtSOff")).Text + "','" + Convert.ToDateTime(gr.Cells[27].Text) + "','" + Convert.ToDateTime(gr.Cells[28].Text) + "')"; objQueryController.ExecuteQuery(strQuery); } } catch { string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[FromDate],[ToDate])"; strQuery += "Values ('" + ((TextBox)gr.FindControl("txtSno")).Text + "','" + ((TextBox)gr.FindControl("txtInvoiceNo")).Text + "','" + ((TextBox)gr.FindControl("txtDate")).Text + "','" + ((TextBox)gr.FindControl("txtDealerCode")).Text + "','" + ((TextBox)gr.FindControl("txtDealerName")).Text + "','" + ((TextBox)gr.FindControl("txtBlank")).Text + "','" + ((TextBox)gr.FindControl("txtModelCode")).Text + "','" + ((TextBox)gr.FindControl("txtQuantity")).Text + "','" + ((TextBox)gr.FindControl("txtSalesAmt")).Text + "','" + ((TextBox)gr.FindControl("txtDiscount")).Text + "','" + ((TextBox)gr.FindControl("txtSPLDIS")).Text + "','" + ((TextBox)gr.FindControl("txtExciseDuty")).Text + "','" + ((TextBox)gr.FindControl("txtEduCess")).Text + "','" + ((TextBox)gr.FindControl("txtHrECess")).Text + "','" + ((TextBox)gr.FindControl("txtLSPD")).Text + "','" + ((TextBox)gr.FindControl("txtMSPSD")).Text + "','" + ((TextBox)gr.FindControl("txtDHC")).Text + "','" + ((TextBox)gr.FindControl("txtTaxable")).Text + "','" + ((TextBox)gr.FindControl("txtCST")).Text + "','" + ((TextBox)gr.FindControl("txtLST")).Text + "','" + ((TextBox)gr.FindControl("txtSurch")).Text + "','" + ((TextBox)gr.FindControl("txtEntityTot")).Text + "','" + ((TextBox)gr.FindControl("txtDelyChgs")).Text + "','" + ((TextBox)gr.FindControl("txtFreight")).Text + "','" + ((TextBox)gr.FindControl("txtNetAmt")).Text + "','" + ((TextBox)gr.FindControl("txtCost")).Text + "','" + ((TextBox)gr.FindControl("txtSOff")).Text + "','" + Convert.ToDateTime(gr.Cells[27].Text) + "','" + Convert.ToDateTime(gr.Cells[28].Text) +"')"; objQueryController.ExecuteQuery(strQuery); } string strDeleteQuery = "Delete from SalesTemp where ID=" + Convert.ToInt16(str); objQueryController.ExecuteQuery(strDeleteQuery); string strGridQuery = "Select * from SalesTemp"; DataTable dt = new DataTable(); dt = objQueryController.ExecuteQuery(strGridQuery); grdSalesException.DataSource = dt; grdSalesException.DataBind(); } } }