// Insertion public ActionResult SaveRecord(String ps_Code, String Location, String Title) { Int32 li_ReturnValue = 0; try { SETUP_LeaveGroup lrow_LeaveGroup = new SETUP_LeaveGroup(); if (String.IsNullOrEmpty(ps_Code)) { if (DALCommon.AutoCodeGeneration("SETUP_LeaveGroup") == 1) { ps_Code = DALCommon.GetMaximumCode("SETUP_LeaveGroup"); } } if (!String.IsNullOrEmpty(ps_Code)) { lrow_LeaveGroup.LevGrp_Id = ps_Code; lrow_LeaveGroup.LevGrp_Code = ps_Code; lrow_LeaveGroup.LevGrp_Title = Title; lrow_LeaveGroup.Loc_Id = Location; lrow_LeaveGroup.LevGrp_Active = 1; li_ReturnValue = objDalLeaveGroup.SaveRecord(lrow_LeaveGroup); ViewData["SaveResult"] = li_ReturnValue; } return PartialView("GridData"); } catch { return PartialView("GridData"); } }
public int SaveRecord(SETUP_LeaveGroup lrow_LeaveGroup) { int li_ReturnValue = 0; try { SCMSDataContext dbSCMS = Connection.Create(); SETUP_LeaveGroup lRow_ExistingData = dbSCMS.SETUP_LeaveGroups.Where(c => c.LevGrp_Id.Equals(lrow_LeaveGroup.LevGrp_Id)).SingleOrDefault(); if (lRow_ExistingData != null) { lRow_ExistingData.LevGrp_Title = lrow_LeaveGroup.LevGrp_Title; lRow_ExistingData.Loc_Id = lrow_LeaveGroup.Loc_Id; } else { dbSCMS.SETUP_LeaveGroups.InsertOnSubmit(lrow_LeaveGroup); } dbSCMS.SubmitChanges(); li_ReturnValue = Convert.ToInt32(lrow_LeaveGroup.LevGrp_Id); } catch { return 0; } return li_ReturnValue; }