Beispiel #1
0
        //先重新生成BLLService,再运行一下commodityBLLService,在浏览器查看然,确保已经创建服务后,再Ui更新服务(这样才能发现服务器端新增的方法)。
        private void buttonSave_Click(object sender, EventArgs e)
        {
            int     inventory = 0;
            decimal unitPrice = 0.0M;

            try
            {
                inventory = int.Parse(textBoxInventory.Text);
                unitPrice = decimal.Parse(textBoxUnitPrice.Text);
            }
            catch
            {
                MessageBox.Show("单价或者库存有误!");
            }
            Model.CommodityModel oneCommodity = new Model.CommodityModel();
            oneCommodity.Name         = textBoxName.Text;
            oneCommodity.Type         = textBoxType.Text;
            oneCommodity.Manufacturer = textBoxManufacturer.Text;
            oneCommodity.Unit         = textBoxUnit.Text;
            oneCommodity.Inventory    = inventory;
            oneCommodity.UnitPrice    = unitPrice;
            //整个应用程序使用一个对象
            BLLCommodity.CommodityManagerServiceClient client = WCFServiceBLL.GetCommodityService();
            try
            {
                if (isUpdate)
                {
                    //获取要更新数据的ID
                    oneCommodity.ID = SID;
                    if (!client.UpdateCommodity(oneCommodity))
                    {
                        MessageBox.Show("更新失败");
                        this.DialogResult = DialogResult.None;
                        return;
                    }
                }
                else
                {
                    if (client.AddCommodity(oneCommodity) == null)
                    {
                        MessageBox.Show("保存失败");
                        this.DialogResult = DialogResult.None;
                    }
                }
            }
            catch (FaultException <Exception> ex)
            {
                MessageBox.Show(ex.Message);
                this.DialogResult = DialogResult.None;
                //后面还会执行吗
            }
        }
Beispiel #2
0
        private void showAllSuppliser()
        {
            BLLCommodity.CommodityManagerServiceClient commodityClient  = WCFServiceBLL.GetCommodityService();
            List <Model.ManufacturerModel>             listManufacturer = commodityClient.GetManufacturers("", "", "", "", "1").ToList();

            combSupplier.Items.Clear();
            //combSupplier.Items.Add();
            foreach (Model.ManufacturerModel oneManufacturer in listManufacturer)
            {
                string key = oneManufacturer.ID + "||" + oneManufacturer.Name;
                combSupplierData.Add(key, oneManufacturer);
                combSupplier.Items.Add(key);
            }
            combSupplier.Items.Insert(0, "请选择供应商");
            combSupplier.Text = "请选择供应商";
        }
Beispiel #3
0
        private void buttonEditName_Click(object sender, EventArgs e)
        {
            SelectCommodity selectCommodityForm = new SelectCommodity();

            if (selectCommodityForm.ShowDialog() == DialogResult.OK)
            {
                SalesCommodityID = selectCommodityForm.SelectedCommodityID;
                if (SalesCommodityID < 1)
                {
                    MessageBox.Show("未选中商品!");
                    return;
                }
                BLLCommodity.CommodityManagerServiceClient client = WCFServiceBLL.GetCommodityService();
                Model.CommodityModel oneCommodity = client.GetOneCommodity(SalesCommodityID);
                textBoxName.Text       = oneCommodity.Name;
                textBoxPrice.Text      = oneCommodity.UnitPrice.ToString();
                labelManufacturer.Text = "[" + oneCommodity.Manufacturer + "]";
                labelPerson.Text       = "[" + oneCommodity.Person + "||" + oneCommodity.Telphone + "]";
                labelAddress.Text      = "[" + oneCommodity.Address;
                labelType.Text         = "[" + oneCommodity.Type + "]";
                labelUnit.Text         = "[" + oneCommodity.Unit + "]";
            }
        }