Пример #1
0
        public ActionResult SaveRecord(String ps_Code, String ps_Title, String ps_CmpId)
        {
            SETUP_Location lrow_Location = new SETUP_Location();
            String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[3], ls_Data = new String[3];
            Int32 li_ReturnValue = 0;

            try
            {
                if (String.IsNullOrEmpty(ps_Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_Location") == 1)
                    {
                        ps_Code = DALCommon.GetMaximumCode("SETUP_Location");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(ps_Code))
                {
                    lrow_Location.Loc_Id = ps_Code;
                    lrow_Location.Loc_Code = ps_Code;
                    lrow_Location.Loc_Title = ps_Title;
                    lrow_Location.Cmp_Id = ps_CmpId;
                    lrow_Location.Loc_Active = 1;

                    li_ReturnValue = objDalLocation.SaveRecord(lrow_Location);
                    ViewData["SaveResult"] = li_ReturnValue;

                    IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues(3)[0];

                    // Audit Trail Entry Section
                    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_Lable[2] = "Company";

                        ls_Data[0] = ps_Code;
                        ls_Data[1] = ps_Title;
                        ls_Data[2] = ps_CmpId;

                        objAuditLog.SaveRecord(2, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                    // Audit Trail Section End
                }

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Пример #2
0
        public int SaveRecord(SETUP_Location pRow_NewData)
        {
            int li_ReturnValue = 0;

            try
            {
                SCMSDataContext dbSCMS = Connection.Create();
                SETUP_Location lRow_ExistingData = dbSCMS.SETUP_Locations.Where(c => c.Loc_Id.Equals(pRow_NewData.Loc_Id)).SingleOrDefault();

                if (lRow_ExistingData != null)
                {
                    lRow_ExistingData.Loc_Title = pRow_NewData.Loc_Title;
                }
                else
                {
                    dbSCMS.SETUP_Locations.InsertOnSubmit(pRow_NewData);
                }
                dbSCMS.SubmitChanges();

                li_ReturnValue = Convert.ToInt32(pRow_NewData.Loc_Id);
            }
            catch
            {
                return 0;
            }

            return li_ReturnValue;
        }