public void UpdateBranch(Vendor.BusinessLayer.BranchBL argBranch, DataTable dtContact) { SqlConnection conn; conn = new SqlConnection(); conn = BsfGlobal.OpenVendorAnalDB(); SqlTransaction tran = conn.BeginTransaction(); string sSql = ""; try { SqlCommand Command = new SqlCommand("Update_Branch", conn, tran); Command.CommandType = CommandType.StoredProcedure; Command.Parameters.Clear(); Command.Parameters.AddWithValue("@BranchId", argBranch.BranchId); Command.Parameters.AddWithValue("@VendorId", argBranch.VendorId); Command.Parameters.AddWithValue("@BranchName", argBranch.BranchName); Command.Parameters.AddWithValue("@Address", argBranch.BranchAddress); Command.Parameters.AddWithValue("@CityId", argBranch.CityId); Command.Parameters.AddWithValue("@TINNo", argBranch.TINNo); Command.Parameters.AddWithValue("@Phone", argBranch.Phone); Command.Parameters.AddWithValue("@ChequeNo", argBranch.ChequeNo); Command.ExecuteNonQuery(); if (dtContact.Rows.Count > 0) { sSql = "Delete BranchTrans Where BranchId=" + argBranch.BranchId + " "; Command = new SqlCommand(sSql, conn, tran); Command.ExecuteNonQuery(); foreach (DataRow dr in dtContact.Rows) { sSql = "Insert Into BranchTrans (BranchId,ContactPerson,Designation,ContactNo,Email,Fax) Values " + "(" + argBranch.BranchId + ",'" + dr["ContactPerson"].ToString() + "','" + dr["Designation"].ToString() + "', " + "'" + dr["ContactNo"].ToString() + "','" + dr["Email"].ToString() + "','" + dr["Fax"].ToString() + "') "; Command = new SqlCommand(sSql, conn, tran); Command.ExecuteNonQuery(); } } tran.Commit(); } catch { tran.Rollback(); } finally { conn.Close(); } }
public void UpdateBranch(Vendor.BusinessLayer.BranchBL argBranch, DataTable dtContact) { m_oBranch.UpdateBranch(argBranch, dtContact); }
public void InsertBranch(Vendor.BusinessLayer.BranchBL argBranch, DataTable dtContact) { m_oBranch.InsertBranch(argBranch, dtContact); }