public void ToStringTest () { NumericUpDown n1 = new NumericUpDown (); Assert.AreEqual ("System.Windows.Forms.NumericUpDown, Minimum = 0, Maximum = 100", n1.ToString (), "1"); n1.Minimum = 0.33m; n1.Maximum = 100.33m; Assert.AreEqual (string.Format (CultureInfo.CurrentCulture, "System.Windows.Forms.NumericUpDown, Minimum = {0}, Maximum = {1}", 0.33, 100.33), n1.ToString (), "2"); }
private void mabn_Validated(object sender, EventArgs e) { if (mabn.Text == "" || mabn.Text.Trim().Length < 3) { return; } if (mabn.Text.Trim().Length != 8) { mabn.Text = mabn.Text.Substring(0, 2) + mabn.Text.Substring(2).PadLeft(6, '0'); } if (bMabn_tudong && mabn.Text == "") { decimal stt = 0; for (; ;) { stt = m.get_mabn(int.Parse(s_mmyy.Substring(0, 2)), 1, 1, true); mabn.Text = s_mmyy.Substring(0, 2) + stt.ToString().PadLeft(6, '0'); if (m.get_data("select * from " + user + ".btdbn where mabn='" + mabn.Text + "'").Tables[0].Rows.Count == 0) { break; } } return; } else if (mabn.Text == "") { return; } bool bFound = false; foreach (DataRow r in m.get_data("select * from " + user + ".kskbtdbn where mabn='" + mabn.Text + "'").Tables[0].Rows) { hoten.Text = r["hoten"].ToString(); namsinh.Text = r["namsinh"].ToString(); phai.SelectedIndex = int.Parse(r["phai"].ToString()); mann.SelectedValue = r["mann"].ToString(); dienthoai.Text = r["dienthoai"].ToString(); diachi.Text = r["diachi"].ToString(); bFound = true; break; } if (!bFound) { foreach (DataRow r in m.get_data("select a.*,b.nha as dienthoai from " + user + ".btdbn a left join " + user + ".dienthoai b on a.mabn=b.mabn where a.mabn='" + mabn.Text + "'").Tables[0].Rows) { hoten.Text = r["hoten"].ToString(); namsinh.Text = r["namsinh"].ToString(); phai.SelectedIndex = int.Parse(r["phai"].ToString()); mann.SelectedValue = r["mann"].ToString(); dienthoai.Text = r["dienthoai"].ToString(); diachi.Text = r["sonha"].ToString().Trim() + " " + r["thon"].ToString(); bFound = true; break; } } hoten.Enabled = !bFound; namsinh.Enabled = hoten.Enabled; phai.Enabled = hoten.Enabled; if (bFound) { butLuu.Focus(); } }
private bool CheckAndSave(System.Windows.Forms.TextBox tbLoc, Mode m) { bool fSave = false; if (m == Mode.MODIFY) { string tbName = tbLoc.Name; string SaveName = tbName.Substring(2, 1); //Original System.Windows.Forms.NumericUpDown oriQty = (System.Windows.Forms.NumericUpDown)pEdit.Controls["cb" + SaveName + "Qty"]; //New System.Windows.Forms.ComboBox cbLoc = (System.Windows.Forms.ComboBox)pEdit.Controls["cb" + SaveName + "Loc"]; System.Windows.Forms.NumericUpDown newQty = (System.Windows.Forms.NumericUpDown)pEdit.Controls["cb" + SaveName + "Qty"]; if ((tbLoc.Text == cbLoc.Text && newQty.Text == oriQty.Text) || (oriQty.Text == "" && newQty.Value == 0)) { //do nothing return(true); } else { //Save if (SaveRecord(tbART_NO.Text, cbLoc.Text, newQty.Text, mRMK.Text, "庫存調整-" + SaveName, "")) { return(true); } } } else if (m == Mode.IN) { string tbName = tbLoc.Name; string SaveName = tbName.Substring(2, 1); //Original System.Windows.Forms.NumericUpDown newQty = (System.Windows.Forms.NumericUpDown)pAction.Controls["cbIn" + SaveName + "Qty"]; System.Windows.Forms.TextBox oriQty = (System.Windows.Forms.TextBox)mPan.Controls["tb" + SaveName + "Qty"]; //New System.Windows.Forms.TextBox Loc = (System.Windows.Forms.TextBox)mPan.Controls["tb" + SaveName + "Loc"]; if (newQty.Value == 0 || oriQty.Text == newQty.ToString()) { //do nothing return(true); } else { //Add in stock amount oriQty.Text = (int.Parse(String.IsNullOrEmpty(oriQty.Text) ? "0" : oriQty.Text) + newQty.Value).ToString(); //Save if (SaveRecord(tbART_NO.Text, Loc.Text, oriQty.Text, mRMK.Text, "存樣-" + SaveName, newQty.Value.ToString())) { return(true); } } } else if (m == Mode.OUT) { string tbName = tbLoc.Name; string SaveName = tbName.Substring(2, 1); //Original System.Windows.Forms.TextBox Loc = (System.Windows.Forms.TextBox) this.Controls[0].Controls["mPan"].Controls["tb" + SaveName + "Loc"]; System.Windows.Forms.TextBox oriQty = (System.Windows.Forms.TextBox) this.Controls[0].Controls["mPan"].Controls["tb" + SaveName + "Qty"]; //New System.Windows.Forms.NumericUpDown newQty = (System.Windows.Forms.NumericUpDown) this.Controls[0].Controls["mPan"].Controls["pAction"].Controls["cbIn" + SaveName + "Qty"]; if (newQty.Value == 0) { //do nothing return(true); } else { //Add in stock amount oriQty.Text = (int.Parse(String.IsNullOrEmpty(oriQty.Text) ? "0" : oriQty.Text) - newQty.Value).ToString(); //Save if (SaveRecord(tbART_NO.Text, Loc.Text, oriQty.Text, mRMK.Text, "取樣-" + SaveName, newQty.Value.ToString())) { return(true); } } } return(fSave); }