public int SaveJobPosition(SETUP_JobPosition newSetupJobPosition) { try { SCMSDataContext dbSCMS = Connection.Create(); SETUP_JobPosition existingSetupJobPosition = dbSCMS.SETUP_JobPositions.Where(c => c.JP_Id.Equals(newSetupJobPosition.JP_Id)).SingleOrDefault(); if (existingSetupJobPosition != null) { existingSetupJobPosition.JP_Title = newSetupJobPosition.JP_Title; existingSetupJobPosition.Cmp_Id = newSetupJobPosition.Cmp_Id; existingSetupJobPosition.Loc_Id = newSetupJobPosition.Loc_Id; existingSetupJobPosition.JP_SortOrder = newSetupJobPosition.JP_SortOrder; existingSetupJobPosition.JP_Active = newSetupJobPosition.JP_Active; existingSetupJobPosition.JP_Remarks = newSetupJobPosition.JP_Remarks; existingSetupJobPosition.JT_Id = newSetupJobPosition.JT_Id; existingSetupJobPosition.Dpt_Id = newSetupJobPosition.Dpt_Id; existingSetupJobPosition.FA_Id = newSetupJobPosition.FA_Id; } else { dbSCMS.SETUP_JobPositions.InsertOnSubmit(newSetupJobPosition); } dbSCMS.SubmitChanges(); return Convert.ToInt32(newSetupJobPosition.JP_Id); } catch { return 0; } }
public ActionResult SaveJobPosition(string Code, string Title, string Remarks,string location, string Job, string Department,string functionalarea) { Int32 JobPositionId = 0; try { SETUP_JobPosition setupJobPositionRow = new SETUP_JobPosition(); if (String.IsNullOrEmpty(Code)) { if (DALCommon.AutoCodeGeneration("SETUP_JobPosition") == 1) { Code = DALCommon.GetMaximumCode("SETUP_JobPosition"); } } if (!String.IsNullOrEmpty(Code)) { setupJobPositionRow.JP_Id = Code; setupJobPositionRow.JP_Code = Code; setupJobPositionRow.JP_Title = Title; setupJobPositionRow.JP_SortOrder = 1; setupJobPositionRow.JP_Active = 1; setupJobPositionRow.JP_Remarks = Remarks; setupJobPositionRow.JT_Id = Job; setupJobPositionRow.Dpt_Id = Department; setupJobPositionRow.FA_Id = functionalarea; setupJobPositionRow.Loc_Id = location; JobPositionId = objDALJobPosition.SaveJobPosition(setupJobPositionRow); ViewData["SaveResult"] = JobPositionId; } return PartialView("GridData"); } catch { return PartialView("GridData"); } }