/// <summary> /// this method is used to update the vendor information with the help of ProsupplierUpdate Procedure /// before check the vendor name should not be duplicate after that update the vendor balance. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, System.EventArgs e) { PartiesClass obj = new PartiesClass(); SqlDataReader SqlDtr = null; try { StringBuilder errorMessage = new StringBuilder(); if (txtTinNo.Text != string.Empty) { string sPattern = "^[a-zA-Z0-9]+$"; if (!System.Text.RegularExpressions.Regex.IsMatch(txtTinNo.Text, sPattern)) { errorMessage.Append("- Please Enter GSTIN No. in Alpha Numeric"); errorMessage.Append("\n"); } } if (errorMessage.Length > 0) { MessageBox.Show(errorMessage.ToString()); return; } string sql1 = ""; if (!TempVenderName.Text.ToLower().Trim().Equals(lblName.Text.ToLower().Trim())) { string sname = lblName.Text.Trim(); sql1 = "select * from Supplier where Supp_Name='" + sname.Trim() + "'"; SqlDtr = obj.GetRecordSet(sql1); if (SqlDtr.HasRows) { MessageBox.Show("Vendor Name " + sname + " Already Exist"); return; } SqlDtr.Close(); sql1 = "select * from Ledger_Master where Ledger_Name='" + sname.Trim() + "'"; SqlDtr = obj.GetRecordSet(sql1); if (SqlDtr.HasRows) { MessageBox.Show("Ledger Name " + sname + " Already Exist"); return; } SqlDtr.Close(); } // sql1 = "Select Tin_No,Supp_ID from supplier where Tin_No = '"+txtTinNo.Text.Trim()+"'"; // SqlDtr= obj.GetRecordSet(sql1); // if(SqlDtr.HasRows) // { // if(SqlDtr.Read()) // { // if(!lblSupplierID.Text.Equals(SqlDtr["Supp_ID"].ToString() ) ) // { // MessageBox.Show("The Tin No. "+txtTinNo.Text.Trim()+" Already Exist"); // return; // } // } // // } // SqlDtr.Close(); obj.Supp_ID = lblSupplierID.Text; obj.Supp_Name = lblName.Text.ToString(); obj.TempCustName = TempVenderName.Text; obj.Supp_Type = DropSuppType.SelectedItem.Value.ToString(); obj.Address = txtAddress.Text.ToString(); obj.City = DropCity.SelectedItem.Value.ToString(); obj.State = DropState.SelectedItem.Value.ToString(); obj.Country = DropCountry.SelectedItem.Value.ToString(); obj.EMail = txtEMail.Text.ToString(); if (txtPhoneRes.Text == "") { obj.Tel_Res = "0"; } else { obj.Tel_Res = txtPhoneRes.Text; } if (txtPhoneOff.Text == "") { obj.Tel_Off = "0"; } else { obj.Tel_Off = txtPhoneOff.Text; } if (txtMobile.Text == "") { obj.Mobile = "0"; } else { obj.Mobile = txtMobile.Text; } if (txtOpBalance.Text == "") { obj.Op_Balance = "0"; } else { obj.Op_Balance = txtOpBalance.Text; } obj.Balance_Type = DropBal.SelectedItem.Value.ToString(); if (DropCrDay.SelectedIndex == 0) { obj.CR_Days = "0"; } else { obj.CR_Days = DropCrDay.SelectedItem.Value.ToString(); } obj.Tin_No = txtTinNo.Text.Trim(); // call function to update the supplier details obj.UpdateSupplier(); string Ledger_ID = ""; dbobj.SelectQuery("select Ledger_ID from Ledger_Master where Ledger_Name=(select Supp_Name from Supplier where Supp_ID='" + lblSupplierID.Text.Trim() + "')", ref SqlDtr); if (SqlDtr.Read()) { Ledger_ID = SqlDtr.GetValue(0).ToString(); } UpdateCustomerBalance(Ledger_ID); MessageBox.Show("Vendor Updated"); Clear(); CreateLogFiles.ErrorLog("Form:Supllier_update.aspx, Method:btnUpdate_Click " + " Supplier_ID " + obj.Supp_ID + " Supplier Name " + lblName.Text.ToString() + " IS UPDATED " + " user " + uid); Response.Redirect("Supplier_List.aspx", false); } catch (Exception ex) { CreateLogFiles.ErrorLog("Form:Supplier_Update.aspx,Class:PartiesClass.cs,Method:btnUpdate_Click(). EXCEPTION " + ex.Message + " user " + uid); } }