private void txtInput_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (txtInput.Text.Length > 3) { return; } if (lc.chkNumberLimit(txtInput.Text)) { label18.Text = "เลขอั้น"; return; } else if (txtInput.Text.Equals("")) { return; } { label18.Text = "OK"; txtUpFocus(); } } }
private void txtInput_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (cboSale.Text.Equals("")) { MessageBox.Show("ไม่ได้เลือก Sale", "ไม่ได้เลือก Sale"); return; } if (txtInput.Text.IndexOf("+") > 0)//ป้อน แบบสูตร จริง { String[] aa = txtInput.Text.Split('+'); String num = aa[0]; if (num.Length == 2)// 2ตัว { /** * 12+50 = 12 บน 50 Enter * 12+50+ = 12 บน 50 Enter 21 บน 50 Enter * 12-50 = 12 ล่าง 50 Enter * 12-50- = 12 ล่าง 50 Enter 21 ล่าง 50 Enter * 12+50+-= 12 บน 50 ล่าง 50 Enter 21 บน 50 ล่าง 50 Enter * **/ if (aa.Length == 2)//12+50 = 12 บน 50 Enter { String up = ""; up = aa[1]; txtUp.Text = up; txtInput.Text = num; txtDown.Text = ""; txtTod.Text = ""; setgdv(); } else if (aa.Length == 3)//12+50+ = 12 บน 50 Enter 21 บน 50 Enter { String up = "", cross = ""; up = aa[1]; cross = aa[2]; if (cross.Equals(""))// 12+50+ = 12 บน 50 Enter 21 บน 50 Enter { txtUp.Text = up; txtInput.Text = num; txtDown.Text = ""; txtTod.Text = ""; setgdv(); num = num.Substring(up.Length - 1) + num.Substring(0, 1); txtInput.Text = num; txtDown.Text = up; txtUp.Text = ""; txtTod.Text = ""; setgdv(); } else if (cross.Equals("-"))//*12+50+-= 12 บน 50 ล่าง 50 Enter 21 บน 50 ล่าง 50 Enter { txtUp.Text = up; txtInput.Text = num; txtDown.Text = up; txtTod.Text = ""; setgdv(); num = num.Substring(up.Length - 1) + num.Substring(0, 1); txtUp.Text = up; txtInput.Text = num; txtDown.Text = up; txtTod.Text = ""; setgdv(); } } } else if (num.Length == 3)// 3ตัว { /** * 3หาง 112+50* * 112+50+- 112 บน50 โต๊ด50 ล่าง50 * 112+50+ 112 บน50 โต๊ด50 **/ if (aa.Length == 2) //3หาง 112+50* { String up = "", cross = ""; up = aa[1]; //cross = aa[2]; if (up.Substring(up.Length - 1).Equals("*"))//* 3หาง 112+50* { char[] thechars = num.ToCharArray(); txtUp.Text = up.Replace("*", ""); txtInput.Text = thechars[0].ToString() + thechars[1].ToString() + thechars[2].ToString();//* 3หาง 112+50* txtDown.Text = ""; txtTod.Text = ""; setgdv(); txtUp.Text = up.Replace("*", ""); txtInput.Text = thechars[0].ToString() + thechars[2].ToString() + thechars[1].ToString();//* 3หาง 121+50* txtDown.Text = ""; txtTod.Text = ""; setgdv(); txtUp.Text = up.Replace("*", ""); txtInput.Text = thechars[2].ToString() + thechars[1].ToString() + thechars[0].ToString();//* 3หาง 211+50* txtDown.Text = ""; txtTod.Text = ""; setgdv(); } } else if (aa.Length == 3)//* 112+50+- 112 บน50 โต๊ด50 ล่าง50 { String up = "", cross = ""; up = aa[1]; cross = aa[2]; if (cross.Equals("-")) { txtUp.Text = up; txtInput.Text = num;//* 112+50+- 112 บน50 โต๊ด50 ล่าง50 txtDown.Text = up; txtTod.Text = up; setgdv(); } } } } else if (txtInput.Text.IndexOf("-") > 0) { String[] aa = txtInput.Text.Split('-'); String num = aa[0]; /** * 12-50 = 12 ล่าง 50 Enter * 12-50- = 12 ล่าง 50 Enter 21 ล่าง 50 Enter * **/ if (aa.Length == 2)//12-50 = 12 ล่าง 50 Enter { String down = ""; down = aa[1]; txtDown.Text = down; txtInput.Text = num; txtUp.Text = ""; txtTod.Text = ""; setgdv(); } else if (aa.Length == 3)//12-50- = 12 ล่าง 50 Enter 21 ล่าง 50 Enter { String down = "", cross = ""; down = aa[1]; cross = aa[2]; if (cross.Equals(""))// 12-50- = 12 ล่าง 50 Enter 21 ล่าง 50 Enter { txtDown.Text = down; txtInput.Text = num; txtUp.Text = ""; txtTod.Text = ""; setgdv(); num = num.Substring(down.Length - 1) + num.Substring(0, 1); txtInput.Text = num; txtDown.Text = down; txtUp.Text = ""; txtTod.Text = ""; setgdv(); } } } else { if (txtInput.Text.Length > 3) { return; } label4.Text = ""; if (lc.chkNumberLimit(txtInput.Text)) { label4.Text = "เลขอั้น"; //label14.Font return; } else { if (txtInput.Text.Equals("")) { return; } label4.Text = "OK"; txtUpFocus(); } } } }