public int SaveRecord(SETUP_CustomerType pRow_NewData) { int li_ReturnValue = 0; try { SCMSDataContext dbSCMS = Connection.Create(); SETUP_CustomerType lRow_ExistingData = dbSCMS.SETUP_CustomerTypes.Where(c => c.CustType_Id.Equals(pRow_NewData.CustType_Id)).SingleOrDefault(); if (lRow_ExistingData != null) { lRow_ExistingData.CustType_Title = pRow_NewData.CustType_Title; } else { dbSCMS.SETUP_CustomerTypes.InsertOnSubmit(pRow_NewData); } dbSCMS.SubmitChanges(); li_ReturnValue = Convert.ToInt32(pRow_NewData.CustType_Id); } catch { return 0; } return li_ReturnValue; }
public ActionResult SaveRecord(String ps_Code, String ps_Title) { SETUP_CustomerType lrow_CustomerType = new SETUP_CustomerType(); String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = ""; String[] ls_Lable = new String[2], ls_Data = new String[2]; Int32 li_ReturnValue = 0; try { if (String.IsNullOrEmpty(ps_Code)) { if (DALCommon.AutoCodeGeneration("SETUP_CustomerType") == 1) { ps_Code = DALCommon.GetMaximumCode("SETUP_CustomerType"); ls_Action = "Add"; } } if (!String.IsNullOrEmpty(ps_Code)) { lrow_CustomerType.CustType_Id = ps_Code; lrow_CustomerType.CustType_Code = ps_Code; lrow_CustomerType.CustType_Title = ps_Title; lrow_CustomerType.CustType_Active = 1; li_ReturnValue = objDalCustomerType.SaveRecord(lrow_CustomerType); ViewData["SaveResult"] = li_ReturnValue; IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0]; // Save Audit Log if (li_ReturnValue > 0 && IsAuditTrail == "1") { DALAuditLog objAuditLog = new DALAuditLog(); ls_UserId = ((SECURITY_User)Session["user"]).User_Id; ls_Lable[0] = "Code"; ls_Lable[1] = "Title"; ls_Data[0] = ps_Code; ls_Data[1] = ps_Title; objAuditLog.SaveRecord(6, ls_UserId, ls_Action, ls_Lable, ls_Data); } // Audit Trail Section End } return PartialView("GridData"); } catch { return PartialView("GridData"); } }