Example #1
0
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.NameEdit.Text.Trim()))
            {
                return;
            }

            if (this.YiBaoEnum.SelectedItem == null)
            {
                return;
            }
            if (bIsEdit)
            {
                Inspect.Name      = this.NameEdit.Text.Trim();
                Inspect.AbbrPY    = this.AbbrPY.Text;
                Inspect.AbbrWB    = this.AbbrWB.Text;
                Inspect.Unit      = this.Unit.Text;
                Inspect.YiBaoEnum = (CommContracts.YiBaoEnum) this.YiBaoEnum.SelectedItem;

                Inspect.Price = decimal.Parse(this.SellPrice.Text);


                CommClient.InspectItem myd = new CommClient.InspectItem();
                if (myd.UpdateInspectItem(Inspect))
                {
                    (this.Parent as Window).DialogResult = true;
                    (this.Parent as Window).Close();
                }
            }
            else
            {
                CommContracts.InspectItem inspect = new CommContracts.InspectItem();
                inspect.Name      = this.NameEdit.Text.Trim();
                inspect.AbbrPY    = this.AbbrPY.Text.Trim();
                inspect.AbbrWB    = this.AbbrWB.Text.Trim();
                inspect.Unit      = this.Unit.Text.Trim();
                inspect.YiBaoEnum = (CommContracts.YiBaoEnum) this.YiBaoEnum.SelectedItem;
                if (!string.IsNullOrEmpty(this.SellPrice.Text))
                {
                    inspect.Price = decimal.Parse(this.SellPrice.Text.Trim());
                }

                CommClient.InspectItem myd = new CommClient.InspectItem();
                if (myd.SaveInspectItem(inspect))
                {
                    (this.Parent as Window).DialogResult = true;
                    (this.Parent as Window).Close();
                }
            }
        }