示例#1
0
        public int SaveRecord(SETUP_Supplier row_Supplier)
        {
            int li_ReturnValue = 0;

            try
            {
                SCMSDataContext dbSCMS = Connection.Create();
                SETUP_Supplier Row_ExistingData = dbSCMS.SETUP_Suppliers.Where(c => c.Supp_Id.Equals(row_Supplier.Supp_Id)).SingleOrDefault();

                if (Row_ExistingData != null)
                {
                    Row_ExistingData.Supp_Code = row_Supplier.Supp_Code;
                    Row_ExistingData.Loc_Id = row_Supplier.Loc_Id;
                    Row_ExistingData.SuppType_Id = row_Supplier.Supp_Id;
                    Row_ExistingData.Supp_Title = row_Supplier.Supp_Title;
                    Row_ExistingData.Supp_Address1 = row_Supplier.Supp_Address1;
                    Row_ExistingData.Supp_Email = row_Supplier.Supp_Email;
                    Row_ExistingData.Supp_Phone = row_Supplier.Supp_Phone;
                    Row_ExistingData.Supp_Fax = row_Supplier.Supp_Fax;
                }
                else
                {
                    dbSCMS.SETUP_Suppliers.InsertOnSubmit(row_Supplier);
                }
                dbSCMS.SubmitChanges();

                li_ReturnValue = Convert.ToInt32(row_Supplier.Supp_Id);
            }
            catch
            {
                return 0;
            }

            return li_ReturnValue;
        }
示例#2
0
        public ActionResult SaveSupplierRecord(String Code, String location, String SupplierType, String Title, String Address, String Email, String Phone, String Fax)
        {
            SETUP_Supplier row_Supplier = new SETUP_Supplier();
            String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[7], ls_Data = new String[7];
            Int32 li_ReturnValue = 0;

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

                if (!String.IsNullOrEmpty(Code))
                {
                    row_Supplier.Supp_Id = Code;
                    row_Supplier.Supp_Code = Code;
                    row_Supplier.Loc_Id = location;
                    row_Supplier.SuppType_Id = SupplierType;
                    row_Supplier.Supp_Title = Title;
                    row_Supplier.Supp_Address1 = Address;
                    row_Supplier.Supp_Email = Email;
                    row_Supplier.Supp_Phone = Phone;
                    row_Supplier.Supp_Fax = Fax;
                    row_Supplier.Supp_Active = 1;
                    row_Supplier.City_Id = "00001";
                    li_ReturnValue = objDalSupplier.SaveRecord(row_Supplier);
                    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_Lable[2] = "Address";
                        ls_Lable[3] = "Supplier Type";
                        ls_Lable[4] = "Email";
                        ls_Lable[5] = "Phone";
                        ls_Lable[6] = "Fax";

                        ls_Data[0] = Code;
                        ls_Data[1] = Title;
                        ls_Data[2] = Address;
                        ls_Data[3] = SupplierType;
                        ls_Data[4] = Email;
                        ls_Data[5] = Phone;
                        ls_Data[6] = Fax;

                        objAuditLog.SaveRecord(5, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                }
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }