Пример #1
0
        private void btnDeleteOrder_Click(object sender, EventArgs e)
        {
            int id = 0; Order order1 = null; RadioButton radioButton1 = null;

            foreach (RadioButton radioButton in radioButtons)
            {
                if (radioButton.Checked == true)
                {
                    radioButton1 = radioButton; id = int.Parse(radioButton.Name);
                }
            }
            foreach (Order order in orders)
            {
                if (order.Id == id)
                {
                    order1 = order;
                }
            }
            if (order1 == null)
            {
                new Tip("请选择一个订单").ShowDialog(); return;
            }
            new Tip(Customer_Service.CancelOrder(order1).Result).ShowDialog();
            pnlOrders.Controls.Clear();
            this.Customer_OrderList_Form_Load(null, null);
        }
Пример #2
0
        }//注册

        private void btnLogin_Click(object sender, EventArgs e) //点击登录按钮
        {
            Customer customer;                                  //当前即将登陆的顾客



            if (int.TryParse(txtId.Text, out int id))
            {
                customer = Customer_Service.Login(id, txtPassword.Text);

                /*Customer customer1 = new Customer();
                 * customer1.Id = 10009;
                 * customer1.Name = "黄昌宇";
                 * customer1.PhoneNum = "123456789";
                 * customer1.Address = "武汉大学信息学部";
                 * customer = customer1;*/
                if (customer == null)
                {
                    new Tip("登陆失败").ShowDialog();
                    return;
                }
                customer.Orders = new List <Order>();
                Customer_Form customer_Form = new Customer_Form(customer, this);
                this.Hide();
                customer_Form.ShowDialog();//打开用户界面
            }
            else
            {
                //判断为五位还没写
                new Tip("账号应为5位的数字").ShowDialog();
                return;
            }
        }
Пример #3
0
 public MainPage()
 {
     this.InitializeComponent();
     customer_service          = new Customer_Service();
     Products.ItemsSource      = customer_service.GetAllProducts();
     Shopping_Cart.ItemsSource = customer_service.GetAllShoppingCartItems();
     ShoppingCart_Block.Text   = $"Cart {customer_service.Total_Price(Shopping_Cart.ItemsSource as IEnumerable<ShoppingCartItem>):c}";
 }
 public ShoppingController()
 {
     this.cart_Service       = new Cart_Service();
     this.item_Service       = new Item_Service();
     this.customer_Service   = new Customer_Service();
     this.order_Service      = new Order_Service();
     this.affiliate_Service  = new Affiliate_Service();
     this.department_Service = new Department_Service();
     this.address_Service    = new Address_Service();
 }
Пример #5
0
        static void Main(string[] args)
        {
            string WSKey = "WOpmr3C4RwHfRfDacAa8tHlrMwbVBc+YKJuyo5OXNls=";

            //Create an instance of the D365BC SOAP WS
            Customer_Service ws = new Customer_Service();

            ws.Url = "https://api.businesscentral.dynamics.com/v1.0/194e87bd-73c6-43c6-95d7-1ca48985db5e/WS/CRONUS%20IT/Page/Customer";
            //Handling authentication
            System.Net.CredentialCache myCredentials = new System.Net.CredentialCache();
            NetworkCredential          netCred       = new NetworkCredential("sdemiliani", WSKey);

            myCredentials.Add(new Uri(ws.Url), "Basic", netCred);
            ws.Credentials = myCredentials;

            //Read Customers
            List <Customer_Filter> filters = new List <Customer_Filter>();
            Customer_Filter        filter  = new Customer_Filter();

            filter.Field    = Customer_Fields.Country_Region_Code;
            filter.Criteria = "IT";
            filters.Add(filter);
            try
            {
                foreach (Customer customer in ws.ReadMultiple(filters.ToArray(), "", 0))
                {
                    Console.WriteLine("No: {0} Name: {1}", customer.No, customer.Name);
                }

                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error retrieving Customers: {0} InnerException: {1}", ex.Message, ex.InnerException);
            }

            //Create the Customer record
            //Customer customer = new Customer();
            //customer.Name = "SOAP Customer 1";
            //customer.Address = "Viale Kennedy 87, Novara";
            //customer.Country_Region_Code = "IT";
            //customer.Blocked = Blocked.Invoice;
            //try
            //{
            //    //Start the Create method
            //    ws.Create(ref customer);
            //    Console.WriteLine("Customer {0} created successfully.", customer.No);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine("Customer creation error: {0} InnerException: {1}", ex.Message, ex.InnerException);
            //}
        }
        private static string PrintCustomerList(Customer_Service service, List <Customer_Filter> filter)
        {
            var sb = new StringBuilder();

            sb.AppendLine("Printing Customer List Soap");

            // Runs the actual search.
            Customer[] list = service.ReadMultiple(filter.ToArray(), null, 100);
            foreach (Customer c in list)
            {
                sb.AppendLine(PrintCustomer(c));
            }
            sb.AppendLine("End of List");
            return(sb.ToString());
        }
Пример #7
0
 private void btnRegister_Click(object sender, EventArgs e)
 {
     if (int.TryParse(txtId.Text, out int id))
     {
         Customer receivedcustomer = Customer_Service.Register(id, txtPassword.Text);
         if (receivedcustomer == null)
         {
             new Tip("注册失败").ShowDialog();
         }
         new Tip("注册成功").ShowDialog();
     }
     else
     {
         //判断为五位的数字
         new Tip("账号需为5位的数字").ShowDialog();
     }
 }
        private static string  TestDynamicsNavSoapService()
        {
            // Creates instance of service and sets credentials.
            Customer_Service service = new Customer_Service();

            service.UseDefaultCredentials = true;

            List <Customer_Filter> filterArray = new List <Customer_Filter>();
            Customer_Filter        nameFilter  = new Customer_Filter();

            nameFilter.Field    = Customer_Fields.Name;
            nameFilter.Criteria = "C*";
            filterArray.Add(nameFilter);

            var customerInfo = PrintCustomerList(service, filterArray);

            return(customerInfo);
        }
Пример #9
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     //用正则表达式改成匹配
     char [] number = txtPhoneNum.Text.ToCharArray();
     for (int i = 0; i < number.Length; i++)
     {
         string x = number[i].ToString();
         if (!int.TryParse(x, out int j))
         {
             new Tip("电话号码需要为数字");
             txtName.Text = name; txtAddress.Text = address; txtPhoneNum.Text = phonenumber;
             return;
         }
     }
     customer.Name     = txtName.Text;
     customer.Address  = txtAddress.Text;
     customer.PhoneNum = txtPhoneNum.Text;
     Customer_Service.ModifyCustomer(customer);
 }
Пример #10
0
        public void sendCustomer(String path)
        {
            try
            {
                var service = new Customer_Service();
                service.UseDefaultCredentials = true;
                service.Credentials           = System.Net.CredentialCache.DefaultCredentials;
                service.Url = "http://Kenedy:7047/DynamicsNAV90/WS/DUALA%20TRADERS%20LIMITED/Page/Customer";


                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(path);
                var        nodeList  = xmlDoc.DocumentElement.SelectNodes("/Table/Customer");
                Customer[] custArray = new Customer[nodeList.Count];
                foreach (XmlNode node in nodeList)
                {
                    for (int i = 0; i < custArray.Length; i++)
                    {
                        custArray[i] = new Customer();

                        custArray[i].Address   = node.SelectSingleNode("Address").InnerText;
                        custArray[i].Name      = node.SelectSingleNode("Name").InnerText;
                        custArray[i].Address_2 = node.SelectSingleNode("Address_2").InnerText;
                        custArray[i].Phone_No  = node.SelectSingleNode("Phone_No").InnerText;
                        custArray[i].E_Mail    = node.SelectSingleNode("E_Mail").InnerText;
                        custArray[i].Customer_Posting_Group = node.SelectSingleNode("Customer_Posting_Group").InnerText;
                        custArray[i].Gen_Bus_Posting_Group  = node.SelectSingleNode("Gen_Bus_Posting_Group").InnerText;
                        custArray[i].VAT_Bus_Posting_Group  = node.SelectSingleNode("VAT_Bus_Posting_Group").InnerText;
                        Console.WriteLine(custArray[i].Name);
                        service.CreateMultiple(ref custArray);
                    }
                }

                MessageBox.Show(nodeList.Count + " " + "Customer(s) data successfully uploaded..!!!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #11
0
        public Select_Merchant_Form(Customer customer, Form form, Form mainForm)
        {
            InitializeComponent();

            this.customer = customer;

            /*Merchant merchant1 = new Merchant();
             * merchant1.Name = "KFC";
             * merchant1.Info = "嫩牛五方限时折扣";
             *
             * Cuisine cuisine = new Cuisine();
             * cuisine.Id = 1;
             * cuisine.Name = "香辣鸡腿堡";
             * cuisine.UnitPrice=7;
             *
             * Cuisine cuisine1 = new Cuisine();
             * cuisine1.Id = 2;
             * cuisine1.Name = "新奥尔良鸡腿堡";
             * cuisine1.UnitPrice = 8;
             *
             * Cuisine cuisine2 = new Cuisine();
             * cuisine1.Id = 3;
             * cuisine1.Name = "牛肉堡";
             * cuisine1.UnitPrice = 7;
             *
             * Cuisine cuisine3 = new Cuisine();
             * cuisine1.Id = 4;
             * cuisine1.Name = "双层牛肉堡";
             * cuisine1.UnitPrice = 10;
             *
             * Cuisine cuisine4 = new Cuisine();
             * cuisine1.Id = 5;
             * cuisine1.Name = "双层鸡腿堡";
             * cuisine1.UnitPrice = 11;
             *
             * Cuisine cuisine5 = new Cuisine();
             * cuisine1.Id = 6;
             * cuisine1.Name = "菌菇堡";
             * cuisine1.UnitPrice = 6;
             *
             * CuisineType cuisineType=new CuisineType();
             * cuisineType.TypeName = "汉堡";
             * cuisineType.Cuisines.Add(cuisine1);
             * cuisineType.Cuisines.Add(cuisine);
             *
             * merchant1.CuisineTypes.Add(cuisineType);
             *
             * CuisineType cuisineType1 = new CuisineType();
             * cuisineType.TypeName = "鸡肉卷";
             *
             * CuisineType cuisineType2 = new CuisineType();
             * cuisineType.TypeName = "薯条";
             * CuisineType cuisineType3 = new CuisineType();
             * cuisineType.TypeName = "饮料";
             * CuisineType cuisineType4 = new CuisineType();
             * cuisineType.TypeName = "小吃";
             * merchant1.CuisineTypes.Add(cuisineType1);
             * merchant1.CuisineTypes.Add(cuisineType2);
             * merchant1.CuisineTypes.Add(cuisineType3);
             * merchant1.CuisineTypes.Add(cuisineType4);
             *
             *
             *
             *
             * Merchant merchant2 = new Merchant();
             * merchant2.Name = "沙县小吃";
             * merchant2.Info = "风味独特、经济实惠";
             *
             *
             * Merchant merchant3 = new Merchant();
             * merchant3.Name = "星巴克";
             * merchant3.Info = "全球著名的咖啡连锁店";
             *
             * Merchant merchant4 = new Merchant();
             * merchant3.Name = "撤硕";
             * merchant3.Info = "老八蜜汁";
             *
             * Merchant merchant5 = new Merchant();
             * merchant3.Name = "汉堡王";
             * merchant3.Info = "最正宗的美式汉堡";
             *
             * Merchant merchant6 = new Merchant();
             * merchant3.Name = "烤肉之家";
             * merchant3.Info = "尽情享受烤肉之旅";
             *
             * Merchant merchant7 = new Merchant();
             * merchant3.Name = "农家餐厅";
             * merchant3.Info = "农家炒菜";
             *
             * merchants.Add(merchant1);
             * merchants.Add(merchant2);
             * merchants.Add(merchant3);
             * merchants.Add(merchant4);
             * merchants.Add(merchant5);
             * merchants.Add(merchant6);
             * merchants.Add(merchant7);*/
            merchants = Customer_Service.GetAllMerchants();

            int i = 0;

            foreach (Merchant merchant in merchants)
            {
                Image            image   = ImageToByte.BytesToImage(merchant.Picture);
                Merchant_Control control = new Merchant_Control(form, mainForm, image);
                control.Merchant_Name = merchant.Name;
                control.Detail        = merchant.Info;
                control.merchant      = merchant;
                control.customer      = customer;
                control.Location      = new Point(20, 90 * i + 10);
                pnlMerchant.Controls.Add(control);

                i++;
            }
        }
Пример #12
0
        private void button2_Click(object sender, EventArgs e)
        {
            Customer_Service customer_Service = new Customer_Service("2", "{ \"user\": {\"name\": \"2\", \"userLongId\": \"2\"}}", "1");

            customer_Service.Show();
        }
Пример #13
0
        private void Customer_OrderList_Form_Load(object sender, EventArgs e)
        {
            this.BackgroundImage      = Image.FromFile(@"素材\灰背景.jpg");
            pnlOrders.BackgroundImage = Image.FromFile(@"素材\白背景.jpg");



            //获取顾客的所有订单
            orders = Customer_Service.GetAllOrders(customer.Id);

            /*Order order1 = new Order(); order1.Id = 1; order1.OrderState = "等待"; order1.OrderTime = "14:30"; order1.TotalPrice = 80;
             * Cuisine cuisine = new Cuisine(); cuisine.Name = "233"; cuisine.UnitPrice = 20;
             * OrderItem orderItem = new OrderItem(); orderItem.Cuisine = cuisine;
             * order1.OrderItems.Add(orderItem);
             * orders = new List<Order>();
             * orders.Add(order1);*/

            int i = 0;

            foreach (Order order in orders)
            {
                Image image = ImageToByte.BytesToImage(order.OrderItems[0].Cuisine.Picture);
                //设置按钮

                RadioButton radioButton = new RadioButton();
                radioButton.Appearance      = Appearance.Button;
                radioButton.Size            = new Size(780, 100);
                radioButton.FlatStyle       = FlatStyle.Flat;
                radioButton.BackgroundImage = Image.FromFile(@"素材\白背景.jpg");
                radioButton.Name            = order.Id.ToString();

                //设置图片
                PictureBox pictureBox = new PictureBox();
                pictureBox.BackgroundImageLayout = ImageLayout.Zoom;
                pictureBox.Image    = ImageToByte.BytesToImage(order.OrderItems[0].Cuisine.Picture);
                pictureBox.Location = new Point(10, 10);
                pictureBox.Size     = new Size(120, 80);

                //设置下单时间
                Label label1 = new Label();
                label1.Size     = new Size(500, 27);
                label1.Text     = "下单时间:" + order.OrderTime;
                label1.Location = new Point(170, 10);
                label1.Font     = new Font("微软雅黑 Light", 10, FontStyle.Regular);

                //设置总价
                Label label2 = new Label();
                label2.Size     = new Size(200, 27);
                label2.Text     = "总价:" + order.OrderState;
                label2.Location = new Point(170, 60);
                label2.Font     = new Font("微软雅黑 Light", 10, FontStyle.Regular);

                //设置状态
                Label label3 = new Label();
                label3.Size     = new Size(300, 27);
                label3.Text     = "订单状态:" + order.OrderState;
                label3.Location = new Point(460, 60);
                label3.Font     = new Font("微软雅黑 Light", 10, FontStyle.Regular);


                radioButton.Controls.Add(pictureBox);
                radioButton.Controls.Add(label1);
                radioButton.Controls.Add(label2);
                radioButton.Controls.Add(label3);
                radioButton.Location = new Point(20, i * 110 + 10);
                pnlOrders.Controls.Add(radioButton);
                radioButtons.Add(radioButton);
                i++;
            }
        }
Пример #14
0
 private void btnSubmit(object sender, EventArgs e)
 {
     new Tip(Customer_Service.AddOrder(order).Result).ShowDialog();
     Close();
 }