public TowelTransaction UpdateTransaction(TowelTransaction objTowelTrans) { try { objTowelTrans.updateDate = DateTime.Now; using (var context = new FitnessCenterEntities()) { context.TowelTransactions.Attach(context.TowelTransactions.Single(x => x.ID == objTowelTrans.ID)); context.TowelTransactions.ApplyCurrentValues(objTowelTrans); context.SaveChanges(); return(objTowelTrans); } } catch (Exception ex) { throw ex; } }
public TowelTransaction InsertTransaction(TowelTransaction objTowelTrans) { try { objTowelTrans.insertDate = DateTime.Now; objTowelTrans.isDeleted = false; using (var context = new FitnessCenterEntities()) { context.TowelTransactions.AddObject(objTowelTrans); context.SaveChanges(); return(objTowelTrans); } } catch (Exception ex) { throw ex; } }
protected void grdTrans_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "EditTowelTrans") { int TowelTransid = Convert.ToInt32(e.CommandArgument); TowelTransaction objTowelTrans = AssignTowelController.GetTransById(TowelTransid); objTowelTrans.isTowelReturn = true; new AssignTowelController().UpdateTransaction(objTowelTrans); BindTransaction(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "succ_msg", "MessageBox('Success','Towel Returned Successfully');", true); } } catch (Exception ex) { throw ex; } }
public void InsertTransaction() { try { TowelHiringMaster objTowelMaster = AssignTowelController.GetAssignedTowelById(TowelMasterId); TowelTransaction objTowelTrans = new TowelTransaction(); long hiringTime = 0; objTowelTrans.towelHiriningId = TowelMasterId; objTowelTrans.memberId = MemberId; objTowelTrans.depositAmount = objTowelMaster.TowelHiringPackage.depositAmount; objTowelTrans.isTowelGiven = true; objTowelTrans.isTowelReturn = false; objTowelTrans = new AssignTowelController().InsertTransaction(objTowelTrans); hiringTime = objTowelMaster.hiringTimeUpdate - 1; objTowelMaster.hiringTimeUpdate = (int)hiringTime; objTowelMaster = new AssignTowelController().UpdateTowelMember(objTowelMaster); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "succ_msg", "MessageBox('Success','Hiring Time Added Successfully');", true); } catch (Exception ex) { throw ex; } }