// Insertion public ActionResult SaveRecord(String ps_Code, String Location, String Title) { Int32 li_ReturnValue = 0; try { SETUP_JobTitle lrow_JobTitle = new SETUP_JobTitle(); if (String.IsNullOrEmpty(ps_Code)) { if (DALCommon.AutoCodeGeneration("SETUP_JobTitle") == 1) { ps_Code = DALCommon.GetMaximumCode("SETUP_JobTitle"); } } if (!String.IsNullOrEmpty(ps_Code)) { lrow_JobTitle.JT_Id = ps_Code; lrow_JobTitle.JT_Code= ps_Code; lrow_JobTitle.JT_Title = Title; lrow_JobTitle.Loc_Id = Location; lrow_JobTitle.JT_Active = 1; li_ReturnValue = objDalJobTitle.SaveRecord(lrow_JobTitle); ViewData["SaveResult"] = li_ReturnValue; } return PartialView("GridData"); } catch { return PartialView("GridData"); } }
public int SaveRecord(SETUP_JobTitle lrow_JobTitle) { int li_ReturnValue = 0; try { SCMSDataContext dbSCMS = Connection.Create(); SETUP_JobTitle lRow_ExistingData = dbSCMS.SETUP_JobTitles.Where(c => c.JT_Id.Equals(lrow_JobTitle.JT_Id)).SingleOrDefault(); if (lRow_ExistingData != null) { lRow_ExistingData.JT_Title = lrow_JobTitle.JT_Title; lRow_ExistingData.Loc_Id = lrow_JobTitle.Loc_Id; } else { dbSCMS.SETUP_JobTitles.InsertOnSubmit(lrow_JobTitle); } dbSCMS.SubmitChanges(); li_ReturnValue = Convert.ToInt32(lrow_JobTitle.JT_Id); } catch { return 0; } return li_ReturnValue; }