protected void BtnUpdate_Click(object sender, EventArgs e) { int i = Convert.ToInt32(hiddenbox.Value); if (i == 0) { int UpdateRow = 0; try { if (ViewState["EditID"] != null) { Entity_Expense.ExpenseHdId = Convert.ToInt32(ViewState["EditID"]); } Entity_Expense.Expense = txtExpense.Text.Trim(); Entity_Expense.UserId = Convert.ToInt32(Session["UserId"]); Entity_Expense.LoginDate = DateTime.Now; UpdateRow = Obj_Expense.UpdateExpense(ref Entity_Expense, out StrError); if (UpdateRow != 0) { Obj_Comm.ShowPopUpMsg("Record Updated Successfully", this.Page); MakeEmptyForm(); Entity_Expense = null; Obj_Comm = null; } } catch (Exception ex) { throw new Exception(ex.Message); } } }
public int UpdateExpense(ref ExpenseNewMaster Entity_Expense, out string StrError) { int iInsert = 0; StrError = string.Empty; try { SqlParameter pAction = new SqlParameter(ExpenseNewMaster._Action, SqlDbType.BigInt); SqlParameter pExpenseHdId = new SqlParameter(ExpenseNewMaster._ExpenseHdId, SqlDbType.BigInt); SqlParameter pExpense = new SqlParameter(ExpenseNewMaster._Expense, SqlDbType.NVarChar); SqlParameter pCreatedBy = new SqlParameter(ExpenseNewMaster._UserId, SqlDbType.BigInt); SqlParameter pCreatedDate = new SqlParameter(ExpenseNewMaster._LoginDate, SqlDbType.DateTime); pAction.Value = 2; pExpenseHdId.Value = Entity_Expense.ExpenseHdId; pExpense.Value = Entity_Expense.Expense; pCreatedBy.Value = Entity_Expense.UserId; pCreatedDate.Value = Entity_Expense.LoginDate; SqlParameter[] param = new SqlParameter[] { pAction, pExpenseHdId, pExpense, pCreatedBy, pCreatedDate }; Open(CONNECTION_STRING); BeginTransaction(); iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, ExpenseNewMaster.SP_ExpenseHeadNewMaster, param); if (iInsert > 0) { CommitTransaction(); } else { RollBackTransaction(); } } catch (Exception ex) { RollBackTransaction(); StrError = ex.Message; } finally { Close(); } return(iInsert); }
protected void BtnSave_Click(object sender, EventArgs e) { int InsertRow = 0; try { DS = Obj_Expense.ChkDuplicate(txtExpense.Text.Trim().ToUpper(), out StrError); if (DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0) { Obj_Comm.ShowPopUpMsg("This Expense Already Exist For ", this.Page); txtExpense.Focus(); } else { Entity_Expense.Expense = txtExpense.Text.Trim(); Entity_Expense.UserId = Convert.ToInt32(Session["UserId"]); Entity_Expense.LoginDate = DateTime.Now; InsertRow = Obj_Expense.InsertExpense(ref Entity_Expense, out StrError); if (InsertRow > 0) { Obj_Comm.ShowPopUpMsg("Record Saved Successfully", this.Page); MakeEmptyForm(); Entity_Expense = null; Obj_Comm = null; } } } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void BtnDelete_Click(object sender, EventArgs e) { //int i = Convert.ToInt32(hiddenbox.Value); //if (i == 0) //{ // try // { // int DeleteId = 0; // if (ViewState["EditID"] != null) // { // if (long.Parse(hdnFldUsedCnt.Value.ToString()) > 0) // { // Obj_Comm.ShowPopUpMsg("Expense Head is in use. Cannot Delete Record...", this.Page); // return; // } // DeleteId = Convert.ToInt32(ViewState["EditID"]); // } // if (DeleteId != 0) // { // Entity_Expense.ExpenseHdId = DeleteId; // Entity_Expense.UserId = Convert.ToInt32(Session["UserId"]); // Entity_Expense.LoginDate = DateTime.Now; // int iDelete = Obj_Expense.DeleteExpense(ref Entity_Expense, out StrError); // if (iDelete != 0) // { // Obj_Comm.ShowPopUpMsg("Record Deleted Successfully..!", this.Page); // MakeEmptyForm(); // } // } // Entity_Expense = null; // Obj_Comm = null; // } // catch (Exception ex) // { // throw new Exception(ex.Message); // } //} int DeleteId = 0; try { if (ViewState["EditID"] != null) { DeleteId = Convert.ToInt32(ViewState["EditID"]); } if (DeleteId != 0) { Entity_Expense.ExpenseHdId = DeleteId; Entity_Expense.UserId = Convert.ToInt32(Session["UserId"]); Entity_Expense.LoginDate = DateTime.Now; int iDelete = Obj_Expense.DeleteExpense(ref Entity_Expense, out StrError); if (iDelete != 0) { Obj_Comm.ShowPopUpMsg("Record Deleted Successfully..!", this.Page); MakeEmptyForm(); } } Entity_Expense = null; Obj_Comm = null; } catch (Exception ex) { throw new Exception(ex.Message); } }