protected void btnFinalSubmit_Click(object sender, EventArgs e) { string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { Dispatch dispatch = new Dispatch(); //dispatch.DispatchDate = (Convert.ToDateTime(txtOrderDate.Text)).ToString("dd-MM-yyyy"); //dispatch.RouteID = Convert.ToInt32(dpagentRoute.SelectedItem.Value); dispatch.DispatchId = Convert.ToInt32(txtDispatchId.Text); DispatchData dispatchData = new DispatchData(); DataSet DS = new DataSet(); updateStock(); DS = dispatchData.GetDetailsForSettlement(dispatch); DS.Tables[0].Columns.Add("ReceivedAmount", typeof(double)); foreach (DataRow dr in DS.Tables[0].Rows) { dr["ReceivedAmount"] = 0; } if (!Comman.Comman.IsDataSetEmpty(DS)) { string nm = GlobalInfo.UserName; //DS.WriteXml(Server.MapPath("~/Tabs/Dispatch/Fsub"+ nm +".xml")); string consString = ConfigurationManager.ConnectionStrings["projectConnection"].ConnectionString; using (SqlConnection con = new SqlConnection(consString)) { using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con)) { //Set the database table name sqlBulkCopy.DestinationTableName = "SettlementDb"; //[OPTIONAL]: Map the DataTable columns with that of the database table (dsColName, dbColName) sqlBulkCopy.ColumnMappings.Add("DD_DispatchInfoId", "DispatchId"); //sqlBulkCopy.ColumnMappings.Add("OrderDetailsID", "DispatchDetailsId"); sqlBulkCopy.ColumnMappings.Add("DD_OrderId", "OrderId"); // sqlBulkCopy.ColumnMappings.Add("OrderDetailsId", "OrderDetailsId"); sqlBulkCopy.ColumnMappings.Add("AgentID", "AgentId"); sqlBulkCopy.ColumnMappings.Add("RouteID", "RouteId"); sqlBulkCopy.ColumnMappings.Add("AgentName", "AgentName"); sqlBulkCopy.ColumnMappings.Add("DispatchDate", "DispatchDate"); sqlBulkCopy.ColumnMappings.Add("OrderDate", "OrderDate"); sqlBulkCopy.ColumnMappings.Add("PaymentMode", "BillingType"); sqlBulkCopy.ColumnMappings.Add("RevisedBill", "FinalBillingAmount"); sqlBulkCopy.ColumnMappings.Add("ReceivedAmount", "ReceivedAmount"); //sqlBulkCopy.ColumnMappings.Add("Qty", "PendingFlag"); //sqlBulkCopy.ColumnMappings.Add("Qty", "BillingType"); con.Open(); sqlBulkCopy.WriteToServer(DS.Tables[0]); con.Close(); } } clearlist(); divDanger.Visible = false; divwarning.Visible = false; divSusccess.Visible = true; lblSuccess.Text = "Information Updated Successfully"; pnlError.Update(); //upMain.Update(); uprouteList.Update(); } } }