private SqlCommand SaveIntimationDetail(mdlIntimations obj_mdlIntimations, SqlTransaction transaction, SqlCommand cmd) { //Delete Intimation Information if (obj_mdlIntimations.dsIntimations.Tables[1].Rows.Count > 0) { cmd = new SqlCommand("Delete from D_Intimations where PK_VoucherID ='" + obj_mdlIntimations.VoucherID + "'", con, transaction); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); } //Inserting Intimation Information for (int i = 0; i <= obj_mdlIntimations.dsIntimations.Tables[1].Rows.Count - 1; i++) { cmd = new SqlCommand("stp_ERP_Intimations_CRUD", con, transaction); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Clear(); cmd.Parameters.Add("@Pk_VoucherID", SqlDbType.VarChar, 9).Value = obj_mdlIntimations.VoucherID; cmd.Parameters.Add("@ProductID", SqlDbType.VarChar, 6).Value = obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Product ID"].ToString().Replace("-",""); cmd.Parameters.Add("@CustomerID", SqlDbType.VarChar, 6).Value = obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Customer ID"].ToString(); cmd.Parameters.Add("@TerritoryID", SqlDbType.VarChar, 4).Value = obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Territory ID"].ToString(); cmd.Parameters.Add("@BatchNo", SqlDbType.VarChar, 15).Value = obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Batch No"].ToString(); cmd.Parameters.Add("@ExpDate", SqlDbType.DateTime).Value = obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Exp. Date"].ToString(); cmd.Parameters.Add("@MfgDate", SqlDbType.DateTime).Value = obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Mfg. Date"].ToString(); cmd.Parameters.Add("@InvQty", SqlDbType.Decimal).Value = obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Qty"].ToString(); cmd.Parameters.Add("@Intimation", SqlDbType.Decimal).Value = obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Intimation"].ToString(); cmd.Parameters.Add("@Return", SqlDbType.Decimal).Value = 0.00;//Convert.ToDouble(obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Intimation"].ToString()); if (obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Adjustment"].ToString() == "") { obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Adjustment"] = "False"; } cmd.Parameters.Add("@Adjustment", SqlDbType.Bit).Value = Convert.ToBoolean(obj_mdlIntimations.dsIntimations.Tables[1].Rows[i]["Adjustment"].ToString()); cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 12).Value = "SaveDetail"; cmd.ExecuteNonQuery(); } return cmd; }
public bool SaveUpdateIntimation(mdlIntimations obj_mdlIntimations, string Operation) { return obj_dalIntimations.SaveUpdateIntimation(obj_mdlIntimations, Operation); }
public bool SaveUpdateIntimation(mdlIntimations obj_mdlIntimations, string Operation) { bool IsSaved = false; if (con.State == ConnectionState.Open) { con.Close(); } con.Open(); SqlTransaction transaction = con.BeginTransaction(); try { //Inserting Master Data in Custoemrs Table SqlCommand cmd = new SqlCommand("stp_ERP_Intimations_CRUD", con, transaction); cmd.Parameters.Add("@Pk_VoucherID", SqlDbType.VarChar, 9).Value = obj_mdlIntimations.VoucherID; cmd.Parameters.Add("@IntimationBookingID", SqlDbType.VarChar, 9).Value = obj_mdlIntimations.BookingID; cmd.Parameters.Add("@VoucherDate", SqlDbType.DateTime).Value = obj_mdlIntimations.VoucherDate; cmd.Parameters.Add("@AddUser", SqlDbType.VarChar, 16).Value = obj_mdlIntimations.AddUser; cmd.Parameters.Add("@LockUser", SqlDbType.VarChar, 16).Value = obj_mdlIntimations.LockUser; cmd.Parameters.Add("@PostUser", SqlDbType.VarChar, 16).Value = obj_mdlIntimations.Postuser; if(Operation == "Save") { cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 12).Value = "SaveMaster"; } else if(Operation == "Update") { cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 12).Value = "Update"; } cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); SaveIntimationDetail(obj_mdlIntimations, transaction, cmd); transaction.Commit(); IsSaved = true; if (con.State == ConnectionState.Open) { con.Close(); } } catch (Exception ex) { transaction.Rollback(); MessageBox.Show(ex.Message, "ERP - Babar Medicine Company Lahore", MessageBoxButtons.OK, MessageBoxIcon.Error); IsSaved = false; if (con.State == ConnectionState.Open) { con.Close(); } } return IsSaved; }