// Insertion public ActionResult SaveRecord(String ps_Code, String Location, String Title) { Int32 li_ReturnValue = 0; try { SETUP_CodeAnalysis6 lrow_CodeAnalysis6 = new SETUP_CodeAnalysis6(); if (String.IsNullOrEmpty(ps_Code)) { if (DALCommon.AutoCodeGeneration("SETUP_CodeAnalysis6") == 1) { ps_Code = DALCommon.GetMaximumCode("SETUP_CodeAnalysis6"); } } if (!String.IsNullOrEmpty(ps_Code)) { lrow_CodeAnalysis6.CA_Id = ps_Code; lrow_CodeAnalysis6.CA_Code = ps_Code; lrow_CodeAnalysis6.CA_Title = Title; lrow_CodeAnalysis6.Loc_Id = Location; lrow_CodeAnalysis6.CA_Active = 1; li_ReturnValue = objDALCodeAnalysis6.SaveRecord(lrow_CodeAnalysis6); ViewData["SaveResult"] = li_ReturnValue; } return PartialView("GridData"); } catch { return PartialView("GridData"); } }
public int SaveRecord(SETUP_CodeAnalysis6 lrow_CodeAnalysis6) { int li_ReturnValue = 0; try { SCMSDataContext dbSCMS = Connection.Create(); SETUP_CodeAnalysis6 lRow_ExistingData = dbSCMS.SETUP_CodeAnalysis6s.Where(c => c.CA_Id.Equals(lrow_CodeAnalysis6.CA_Id)).SingleOrDefault(); if (lRow_ExistingData != null) { lRow_ExistingData.CA_Title = lrow_CodeAnalysis6.CA_Title; lRow_ExistingData.Loc_Id = lrow_CodeAnalysis6.Loc_Id; } else { dbSCMS.SETUP_CodeAnalysis6s.InsertOnSubmit(lrow_CodeAnalysis6); } dbSCMS.SubmitChanges(); li_ReturnValue = Convert.ToInt32(lrow_CodeAnalysis6.CA_Id); } catch { return 0; } return li_ReturnValue; }