Ejemplo n.º 1
0
        public int SaveVoucherType(SETUP_VoucherType newSetupVoucherType)
        {
            try
            {
                SCMSDataContext dbSCMS = Connection.Create();
                SETUP_VoucherType existingSetupVoucherType = dbSCMS.SETUP_VoucherTypes.Where(c => c.VchrType_Id.Equals(newSetupVoucherType.VchrType_Id)).SingleOrDefault();
                if (existingSetupVoucherType != null)
                {
                    existingSetupVoucherType.VchrType_Title = newSetupVoucherType.VchrType_Title;
                    existingSetupVoucherType.VchrType_Prefix = newSetupVoucherType.VchrType_Prefix;
                    existingSetupVoucherType.VchrType_Active = newSetupVoucherType.VchrType_Active;
                    existingSetupVoucherType.VchrType_CodeInitialization = newSetupVoucherType.VchrType_CodeInitialization;
                    existingSetupVoucherType.VchrType_SortOrder = newSetupVoucherType.VchrType_SortOrder;
                    //existingSetupVoucherType.Loc_Id = newSetupVoucherType.Loc_Id;
                    existingSetupVoucherType.Cmp_Id = newSetupVoucherType.Cmp_Id;

                }
                else
                {
                    dbSCMS.SETUP_VoucherTypes.InsertOnSubmit(newSetupVoucherType);
                }
                dbSCMS.SubmitChanges();
                return Convert.ToInt32(newSetupVoucherType.VchrType_Id);
            }
            catch
            {
                return 0;
            }
        }
Ejemplo n.º 2
0
        public ActionResult SaveVoucherType(String Code, String Title, String Prefix, int CodeInitilization)
        {
            SETUP_VoucherType setupVoucherTypeRow = new SETUP_VoucherType();
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[4], ls_Data = new String[4];
            Int32 li_ReturnValue = 0;

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

                if (!String.IsNullOrEmpty(Code))
                {
                    setupVoucherTypeRow.VchrType_Id = Code;
                    setupVoucherTypeRow.VchrType_Code = Code;
                    setupVoucherTypeRow.VchrType_Title = Title;
                    setupVoucherTypeRow.VchrType_Prefix = Prefix;
                    setupVoucherTypeRow.VchrType_CodeInitialization = CodeInitilization;
                    setupVoucherTypeRow.VchrType_SortOrder = 1;
                    setupVoucherTypeRow.VchrType_Active = 1;
                    li_ReturnValue = objDALVoucherType.SaveVoucherType(setupVoucherTypeRow);

                    ViewData["SaveResult"] = li_ReturnValue;

                    IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[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] = "Prefix";
                        ls_Lable[3] = "Code Initialization";

                        ls_Data[0] = Code;
                        ls_Data[1] = Title;
                        ls_Data[2] = Prefix;
                        ls_Data[3] = CodeInitilization.ToString();

                        objAuditLog.SaveRecord(8, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                    // Audit Trail Section End
                }
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }