示例#1
0
        public int SaveRecord(SETUP_Customer row_Customer)
        {
            int li_ReturnValue = 0;

            try
            {
                SCMSDataContext dbSCMS = Connection.Create();
                SETUP_Customer Row_ExistingData = dbSCMS.SETUP_Customers.Where(c => c.Cust_Id.Equals(row_Customer.Cust_Id)).SingleOrDefault();

                if (Row_ExistingData != null)
                {
                    Row_ExistingData.Cust_Code = row_Customer.Cust_Code;
                    Row_ExistingData.Loc_Id = row_Customer.Loc_Id;
                    Row_ExistingData.CustType_Id = row_Customer.CustType_Id;
                    Row_ExistingData.Cust_Title = row_Customer.Cust_Title;
                    Row_ExistingData.Cust_Address1 = row_Customer.Cust_Address1;
                    Row_ExistingData.Cust_Email = row_Customer.Cust_Email;
                    Row_ExistingData.Cust_Phone = row_Customer.Cust_Phone;
                    Row_ExistingData.Cust_Fax = row_Customer.Cust_Fax;

                }
                else
                {
                    dbSCMS.SETUP_Customers.InsertOnSubmit(row_Customer);
                }
                dbSCMS.SubmitChanges();

                li_ReturnValue = Convert.ToInt32(row_Customer.Cust_Id);
            }
            catch
            {
                return 0;
            }

            return li_ReturnValue;
        }
示例#2
0
        public ActionResult SaveCustomerRecord(String Code, String location, String CustomerType, String Title, String Address, String Email, String Phone, String Fax)
        {
            SETUP_Customer row_Customer = new SETUP_Customer();
            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_Customer") == 1)
                    {
                        Code = DALCommon.GetMaximumCode("SETUP_Customer");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(Code))
                {
                    row_Customer.Cust_Id = Code;
                    row_Customer.Cust_Code = Code;
                    row_Customer.Loc_Id = location;
                    row_Customer.CustType_Id = CustomerType;
                    row_Customer.Cust_Title = Title;
                    row_Customer.Cust_Address1 = Address;
                    row_Customer.City_Id = "00001";
                    row_Customer.Cust_Email = Email;
                    row_Customer.Cust_Phone = Phone;
                    row_Customer.Cust_Fax = Fax;
                    row_Customer.Cust_Active = 1;
                    li_ReturnValue = objDALCustomer.SaveRecord(row_Customer);
                    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] = "Customer 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] = CustomerType;
                        ls_Data[4] = Email;
                        ls_Data[5] = Phone;
                        ls_Data[6] = Fax;

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