示例#1
0
        public string SaveCustomer(SaveCustomer request)
        {
            if (request == null)
            {
                ArgumentNullException ex = new ArgumentNullException("GetCustomer request");
                LogError(ex);
                return("获得保存数据失败!");
            }
            WMS_CustomerAccessor accessor = new WMS_CustomerAccessor();
            Customer             customer = new Customer();

            customer.Code        = request.Code;
            customer.Name        = request.Name;
            customer.Description = request.Description;
            try
            {
                if (accessor.SaveCustomer(customer) == -1)
                {
                    return("项目名称在数据中已存在!");
                }
                else
                {
                    return("保存成功!");
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                return("保存失败!" + ex.Message);
            }
        }
示例#2
0
        private void ToolStripLabel1_Click(object sender, EventArgs e)
        {
            bool check;

            if (SaveCustomer.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            switch (SaveCustomer.FilterIndex)
            {
            case 2:
                check = ExportToExcel.Instance.Export(dataGridViewCustomer, SaveCustomer.FileName, ModeExportToExcel.XLSX);
                break;

            case 3:
                check = ExportToExcel.Instance.Export(dataGridViewCustomer, SaveCustomer.FileName, ModeExportToExcel.PDF);
                break;

            default:
                check = ExportToExcel.Instance.Export(dataGridViewCustomer, SaveCustomer.FileName, ModeExportToExcel.XLS);
                break;
            }
            if (check)
            {
                MessageBox.Show("Xuất file thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Lỗi (Cần cài đặt Office)", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            var customer = new Customer
            {
                Id    = 1,
                Name  = "John",
                Email = "*****@*****.**"
            };

            var repository = new PostgresSave();

            var saveCustomer = new SaveCustomer(repository);

            saveCustomer.SaveAndValidate(customer);

            Console.WriteLine("Hello World!");
        }
示例#4
0
        public static SaveCustomer ToSaveCommand(this CustomerModel model, Customer customer)
        {
            Process(model);

            // TODO: add new note and subscriptions
            var command = new SaveCustomer
            {
                CustomerId                  = model.CustomerId,
                FirstName                   = model.FirstName,
                LastName                    = model.LastName,
                MiddleName                  = model.MiddleName,
                EmailAddress                = string.IsNullOrWhiteSpace(model.EmailAddress) ? null : model.EmailAddress,
                ProfileDateUtc              = model.ProfileDateUtc.HasValue ? (DateTime?)model.ProfileDateUtc.Value.ToUniversalTime() : null,
                PreferredLanguage           = model.PreferredLanguage,
                Gender                      = model.Gender,
                CanSendSMSToCell            = model.CanSendSMSToCell,
                Spouse                      = model.Spouse,
                ReferredBy                  = model.ReferredBy,
                Employer                    = model.Employer,
                Occupation                  = model.Occupation,
                LearningTopicsOfInterest    = new HashSet<string>(model.LearningTopicsOfInterest),
                PreferredShoppingMethods    = new HashSet<ShoppingMethod>(model.PreferredShoppingMethods),
                PreferredContactDays        = new HashSet<ContactDay>(model.PreferredContactDays),
                PreferredContactMethods     = new HashSet<ContactMethod>(model.PreferredContactMethods),
                PreferredContactFrequencies = new HashSet<ContactFrequency>(model.PreferredContactFrequencies),
                PreferredContactTimes       = new HashSet<ContactTime>(model.PreferredContactTimes),
                PhoneNumbers                = model.PhoneNumbers,
                Addresses                   = model.Addresses,
                Note                        = string.IsNullOrWhiteSpace(model.Note) ? null : model.Note
            };

            var bookMarks = customer.HyperLinks.Values.Where(h => h.HyperLinkType == HyperLinkType.Bookmark);

            command.HyperLinks = model.SocialNetworks
                                 .Select
               (
                   sn =>
                   new HyperLink
                   {
                       CustomerId = model.CustomerId, // This is lame. Need to fix in Quartet
                       HyperLinkKey = sn.Key,
                       HyperLinkType = sn.Type,
                       Url = new UriBuilder(sn.Url).Uri
                   }
               )
               .Concat(bookMarks).ToArray();

            command.EmailSubscriptions = model.Subscriptions
                .Select
                (
                    sb =>
                    new SaveCustomer.EmailSubscription
                    {
                        SubscriptionType = sb.SubscriptionType,
                        Status           = sb.SubscriptionStatus
                    }
                )
                .ToArray();

            var specialOccasions = model.ImportantDates
                .Select
                (
                    i => new SpecialOccasion
                    {
                        SpecialOccasionKey  = i.Key,
                        SpecialOccasionType = i.Type.Value,
                        Month               = i.Month,
                        Day                 = i.Day,
                        Year                = i.Year,
                        Description         = i.Description
                    }
                );

            if (model.Birthday != null && model.Birthday.Month != 0 && model.Birthday.Day != 0)
                specialOccasions = specialOccasions.Concat
                (
                    new[]
                    {
                        new SpecialOccasion
                        {
                            SpecialOccasionKey  = model.Birthday.Key,
                            SpecialOccasionType = model.Birthday.Type.Value,
                            Month               = model.Birthday.Month,
                            Day                 = model.Birthday.Day,
                            Year                = model.Birthday.Year
                        }
                    }
                );

            if (model.Anniversary != null && model.Anniversary.Month != 0 && model.Anniversary.Day != 0)
                specialOccasions = specialOccasions.Concat
                (
                    new[]
                    {
                        new SpecialOccasion
                        {
                            SpecialOccasionKey  = model.Anniversary.Key,
                            SpecialOccasionType = model.Anniversary.Type.Value,
                            Month               = model.Anniversary.Month,
                            Day                 = model.Anniversary.Day,
                            Year                = model.Anniversary.Year
                        }
                    }
                );

            command.SpecialOccasions = specialOccasions.ToArray();

            command.QuestionnaireItems = MapQuestionnaireAnswers(model.ProfileQuestionGroups);

            return command;
        }
示例#5
0
        public void Post([FromBody] Customer value)
        {
            IInsertCustomer insertObject = new SaveCustomer();

            insertObject.InsertCustomer(value);
        }