diff --git a/BWP.WinFormControl/UComboBox.cs b/BWP.WinFormControl/UComboBox.cs index 9d10920..02213e4 100644 --- a/BWP.WinFormControl/UComboBox.cs +++ b/BWP.WinFormControl/UComboBox.cs @@ -18,15 +18,24 @@ namespace BWP.WinFormControl this.DropDown += (sender, de) => { CRefreshItems(); - //if (string.IsNullOrEmpty(this.Text)) - // return; + if (string.IsNullOrEmpty(this.Text)) + return; - //if (_enableTopItem && Items.Count > 1) - // this.SelectedIndex = 1; - //else if (!_enableTopItem && Items.Count > 0) - // this.SelectedIndex = 0; + if (_enableTopItem && Items.Count > 1) + this.SelectedIndex = 1; + else if (!_enableTopItem && Items.Count > 0) + this.SelectedIndex = 0; SelectionStart = Text.Length; }; + this.SelectedIndexChanged += (sender, e) => + { + var item = SelectedItem as WordPair; + if (item.DisplayName == string.Empty) + _selectedObj = null; + else + _selectedObj = item; + }; + this.DrawMode = DrawMode.OwnerDrawFixed; this.DrawItem += new DrawItemEventHandler(cb_DrawItem); this.DropDownClosed += new EventHandler(cb_DropDownClosed); @@ -90,23 +99,10 @@ namespace BWP.WinFormControl } } - private new WordPair SelectedValue - { - get - { - if (this.SelectedItem == null) - return null; - var result = this.SelectedItem as WordPair; - if (string.IsNullOrEmpty(result.PhyName) && string.IsNullOrEmpty(result.DisplayName)) - return null; - return result; - } - } - void CRefreshItems() { var inputArgs = string.Empty; - if (this.SelectedValue == null) + if (this.SelectedItem == null) inputArgs = this.Text; var list = ComboBoxHelper.GetList(rpcPath, inputArgs, CodeArgs, Range); if (_enableTopItem) @@ -118,58 +114,44 @@ namespace BWP.WinFormControl this.ValueMember = "PhyName"; } - public void Fill(string displayValue, string phyValue) - { - this.SelectedText = displayValue; - - this.SelectedItem = new WordPair(displayValue, phyValue); - } - public void Clear() { - this.Text = null; - this.SelectedText = null; - this.SelectedItem = null; - } - - public bool IsEmpty - { - get { return SelectedValue == null; } + _selectedObj = null; + this.Text = string.Empty; } - public string DisplayValue + public void Fill(string display, string value) { - get + if (string.IsNullOrEmpty(display)) { - if (SelectedValue == null) - return string.Empty; - return SelectedValue.DisplayName; + Clear(); + return; } + _selectedObj = new WordPair(display, value); + this.Text = display == null ? string.Empty : display; } - public string Value - { - get - { - if (SelectedValue == null) - return string.Empty; - return SelectedValue.PhyName; - } - } + public bool IsEmpty { get { return _selectedObj == null; } } + + public string DisplayValue { get { if (IsEmpty) return null; return _selectedObj.DisplayName; } } + + public string Value { get { if (IsEmpty) return null; return _selectedObj.PhyName; } } public long? LongValue { get { - if (SelectedValue == null) + if (IsEmpty) return null; long v; - if (long.TryParse(SelectedValue.PhyName, out v)) + if (long.TryParse(_selectedObj.PhyName, out v)) return v; return null; } } + private WordPair _selectedObj = new WordPair(); + protected override void OnDropDown(EventArgs e) { base.OnDropDown(e); diff --git a/ButcherWeight/WeightForm.cs b/ButcherWeight/WeightForm.cs index 0dba1d3..40853ab 100644 --- a/ButcherWeight/WeightForm.cs +++ b/ButcherWeight/WeightForm.cs @@ -168,7 +168,6 @@ namespace ButcherWeight return false; } - void BindWeightBill() { billGrid.DataSource = dmoList.OrderByDescending(x => x.ID).OrderBy(x => x.FinishWeight).ToList(); @@ -217,6 +216,7 @@ namespace ButcherWeight BindWeightBill(); if (result) MessageBox.Show("保存成功!"); + AppToUI(); } private void createBtn_Click(object sender, EventArgs e) @@ -310,7 +310,6 @@ namespace ButcherWeight Dmo.LiveVarieties_Name = liveVarietiesSelect.DisplayValue; Dmo.HogGrade_ID = hogGradeSelect.LongValue; Dmo.HogGrade_Name = hogGradeSelect.DisplayValue; - if (!string.IsNullOrEmpty(penWeightInput.Text)) { decimal pw = 0; @@ -561,7 +560,7 @@ namespace ButcherWeight private void penWeightPriceInput_TextChanged(object sender, EventArgs e) { decimal w = 0; - decimal price= 0; + decimal price = 0; if (decimal.TryParse(penWeightInput.Text, out w) && decimal.TryParse(penPriceInput.Text, out price)) penMoneyInput.Text = (w * price).ToString("#0.######"); else diff --git a/Setup/Release/Setup.msi b/Setup/Release/Setup.msi index 8e71296..bbdb7d8 100644 Binary files a/Setup/Release/Setup.msi and b/Setup/Release/Setup.msi differ diff --git a/WeighAndGrading/GradeFrom.cs b/WeighAndGrading/GradeFrom.cs index d3a70b4..75e6bfc 100644 --- a/WeighAndGrading/GradeFrom.cs +++ b/WeighAndGrading/GradeFrom.cs @@ -417,7 +417,7 @@ namespace WeighAndGrading this.Invoke(new InvokeHandler(delegate() { lblChengZhong.Text = _displayValue; - //AddWeightDetail(decimal.Parse(_displayValue)); + AddWeightDetail(decimal.Parse(_displayValue)); })); } //WinApiSendMessage.SendMessage(MainHandle, WmUpdDisplayMessage, 0, 0);