Browse Source

修改。

master
yibo 8 years ago
parent
commit
ac4fbcde4a
4 changed files with 36 additions and 55 deletions
  1. +33
    -51
      BWP.WinFormControl/UComboBox.cs
  2. +2
    -3
      ButcherWeight/WeightForm.cs
  3. BIN
      Setup/Release/Setup.msi
  4. +1
    -1
      WeighAndGrading/GradeFrom.cs

+ 33
- 51
BWP.WinFormControl/UComboBox.cs View File

@ -18,15 +18,24 @@ namespace BWP.WinFormControl
this.DropDown += (sender, de) => this.DropDown += (sender, de) =>
{ {
CRefreshItems(); 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; 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.DrawMode = DrawMode.OwnerDrawFixed;
this.DrawItem += new DrawItemEventHandler(cb_DrawItem); this.DrawItem += new DrawItemEventHandler(cb_DrawItem);
this.DropDownClosed += new EventHandler(cb_DropDownClosed); 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() void CRefreshItems()
{ {
var inputArgs = string.Empty; var inputArgs = string.Empty;
if (this.SelectedValue == null)
if (this.SelectedItem == null)
inputArgs = this.Text; inputArgs = this.Text;
var list = ComboBoxHelper.GetList(rpcPath, inputArgs, CodeArgs, Range); var list = ComboBoxHelper.GetList(rpcPath, inputArgs, CodeArgs, Range);
if (_enableTopItem) if (_enableTopItem)
@ -118,58 +114,44 @@ namespace BWP.WinFormControl
this.ValueMember = "PhyName"; this.ValueMember = "PhyName";
} }
public void Fill(string displayValue, string phyValue)
{
this.SelectedText = displayValue;
this.SelectedItem = new WordPair(displayValue, phyValue);
}
public void Clear() 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 public long? LongValue
{ {
get get
{ {
if (SelectedValue == null)
if (IsEmpty)
return null; return null;
long v; long v;
if (long.TryParse(SelectedValue.PhyName, out v))
if (long.TryParse(_selectedObj.PhyName, out v))
return v; return v;
return null; return null;
} }
} }
private WordPair _selectedObj = new WordPair();
protected override void OnDropDown(EventArgs e) protected override void OnDropDown(EventArgs e)
{ {
base.OnDropDown(e); base.OnDropDown(e);


+ 2
- 3
ButcherWeight/WeightForm.cs View File

@ -168,7 +168,6 @@ namespace ButcherWeight
return false; return false;
} }
void BindWeightBill() void BindWeightBill()
{ {
billGrid.DataSource = dmoList.OrderByDescending(x => x.ID).OrderBy(x => x.FinishWeight).ToList(); billGrid.DataSource = dmoList.OrderByDescending(x => x.ID).OrderBy(x => x.FinishWeight).ToList();
@ -217,6 +216,7 @@ namespace ButcherWeight
BindWeightBill(); BindWeightBill();
if (result) if (result)
MessageBox.Show("保存成功!"); MessageBox.Show("保存成功!");
AppToUI();
} }
private void createBtn_Click(object sender, EventArgs e) private void createBtn_Click(object sender, EventArgs e)
@ -310,7 +310,6 @@ namespace ButcherWeight
Dmo.LiveVarieties_Name = liveVarietiesSelect.DisplayValue; Dmo.LiveVarieties_Name = liveVarietiesSelect.DisplayValue;
Dmo.HogGrade_ID = hogGradeSelect.LongValue; Dmo.HogGrade_ID = hogGradeSelect.LongValue;
Dmo.HogGrade_Name = hogGradeSelect.DisplayValue; Dmo.HogGrade_Name = hogGradeSelect.DisplayValue;
if (!string.IsNullOrEmpty(penWeightInput.Text)) if (!string.IsNullOrEmpty(penWeightInput.Text))
{ {
decimal pw = 0; decimal pw = 0;
@ -561,7 +560,7 @@ namespace ButcherWeight
private void penWeightPriceInput_TextChanged(object sender, EventArgs e) private void penWeightPriceInput_TextChanged(object sender, EventArgs e)
{ {
decimal w = 0; decimal w = 0;
decimal price= 0;
decimal price = 0;
if (decimal.TryParse(penWeightInput.Text, out w) && decimal.TryParse(penPriceInput.Text, out price)) if (decimal.TryParse(penWeightInput.Text, out w) && decimal.TryParse(penPriceInput.Text, out price))
penMoneyInput.Text = (w * price).ToString("#0.######"); penMoneyInput.Text = (w * price).ToString("#0.######");
else else


BIN
Setup/Release/Setup.msi View File


+ 1
- 1
WeighAndGrading/GradeFrom.cs View File

@ -417,7 +417,7 @@ namespace WeighAndGrading
this.Invoke(new InvokeHandler(delegate() this.Invoke(new InvokeHandler(delegate()
{ {
lblChengZhong.Text = _displayValue; lblChengZhong.Text = _displayValue;
//AddWeightDetail(decimal.Parse(_displayValue));
AddWeightDetail(decimal.Parse(_displayValue));
})); }));
} }
//WinApiSendMessage.SendMessage(MainHandle, WmUpdDisplayMessage, 0, 0); //WinApiSendMessage.SendMessage(MainHandle, WmUpdDisplayMessage, 0, 0);


Loading…
Cancel
Save