private void simpleButtonXN_Click(object sender, EventArgs e) { if (opt == 1) { if (txtDuongDan.Text == null || txtTenFile.Text == null) { MessageBox.Show("Bạn phải nhập đủ thông tin", "Error???"); } else { Dem fdem = new Dem(txtTenFile.Text, txtDuongDan.Text); if (demSql.Insert_FileDem(fdem) == true) { MessageBox.Show("Thêm thành công!"); simpleButtonHuy.Visible = false; simpleButtonXN.Visible = false; txtDuongDan.ReadOnly = true; txtTenFile.ReadOnly = true; loadTable(); } } } else if (opt == 2) { if (txtDuongDan.Text == null || txtTenFile.Text == null) { MessageBox.Show("Bạn phải nhập đủ thông tin", "Error???"); } else { Dem fdem = new Dem(txtTenFile.Text, txtDuongDan.Text); if (demSql.UpdateDem(fdem) == true) { MessageBox.Show("Sửa thành công!"); simpleButtonHuy.Visible = false; simpleButtonXN.Visible = false; txtDuongDan.ReadOnly = true; loadTable(); } } } else if (opt == 3) { if (txtTenFile.Text == null) { MessageBox.Show("Bạn phải chọn 1 file trong bảng", "Error???"); } else { Dem fdem = new Dem(txtTenFile.Text, txtDuongDan.Text); if (demSql.DeleteDem(fdem) == true) { MessageBox.Show("Xóa thành công!"); simpleButtonHuy.Visible = false; simpleButtonXN.Visible = false; loadTable(); } } } }
//public static void Sleep(int millisecondsTimeout); private void btnLogin_Click(object sender, EventArgs e) { btnLogin.Enabled = true; DataClasses1DataContext db = new DataClasses1DataContext(); var querryLogIn = from User in db.Users where User.Email == txtUsername.Text && User.Password == txtPassword.Text select User; bool check = true; if (querryLogIn.FirstOrDefault() != null) { check = querryLogIn.FirstOrDefault().Active.Value; } if (querryLogIn.Count() == 0) { Dem++; textBox1.Text = Dem.ToString(); MessageBox.Show("Incorrect username or password.", "Notification"); this.txtUsername.Focus(); if (Dem % 3 == 0) { MessageBox.Show("Please wait 10 seconds", "Notification"); btnLogin.Enabled = false; //btnExit.Enabled = false; timer1 = new System.Windows.Forms.Timer(); timer1.Tick += new EventHandler(timer1_Tick_1); timer1.Interval = 1000; // 1 second timer1.Start(); label1.Text = Counter.ToString(); //btnExit.Enabled = true; } //Thread.Sleep(10); label1.Text = " "; } else if (!check) { MessageBox.Show("User not active, please try again!!!", "Notification"); } else { Administrator ad = new Administrator(); this.Hide(); ad.Show(); } }
private string MoneyToString(decimal Amount) { string Resp, Tien, DOC, Dem, Nhom, Chu, So1, So2, So3, Dich; int S; if (Amount == 0) { Resp = "Không đồng"; } else { if (Amount > 999999999999) { Resp = "Số quá lớn"; } else { if (Amount < 0) { Resp = "Trừ"; } else { Resp = string.Empty; } Tien = string.Format("{0:###########0.00}", decimal.Parse(Amount.ToString())); Tien = (Tien.PadLeft(15)); DOC = Dem = string.Empty; DOC = DOC + "trăm mươi tỷ "; DOC = DOC + "trăm mươi triệu "; DOC = DOC + "trăm mươi ngàn "; DOC = DOC + "trăm mươi đồng "; DOC = DOC + "trăm mươi xu "; Dem = Dem + "một hai ba bốn năm "; Dem = Dem + "sáu bảy tám chín"; for (int i = 1; i < 6; i++) { Nhom = Tien.Substring(i * 3 - 3, 3); if (Nhom != "".PadRight(3)) { switch (Nhom) { case "000": Chu = (i == 4 ? "đồng " : ""); break; case ".00": Chu = "chẵn"; break; default: So1 = Nhom.Substring(0, 1); So2 = Nhom.Substring(1, 1); So3 = Nhom.Substring(Nhom.Length > 1 ? Nhom.Length - 1 : 0, 1); Chu = ""; for (int j = 1; j < 4; j++) { Dich = ""; if (int.TryParse(Nhom.Substring(j - 1, 1), out S) == false) { S = -1; } if (S > 0) { Dich = Dem.Substring(S * 5 - 5, 4).Trim() + " "; Dich += DOC.Substring((i - 1) * 18 + j * 6 - 5 - 1, 5) + " "; } switch (j) { case 2: if (S == 1) { Dich = "mười "; } else if (S == 0 && So3 != "0") { if ((int.Parse(So1) >= 1 && int.Parse(So1) <= 9) || (So1 == "0" && i == 4)) { Dich = "lẻ "; } } break; case 3: if (S == 0 && Nhom != "".PadRight(2) + "0") { Dich = DOC.Substring((i - 1) * 18 + j * 6 - 5 - 1, 5).Trim() + "".PadRight(1); } else if (S == 5 && So2 != "".PadRight(1) && So2 != "0") { Dich = "l" + Dich.Substring(1); } break; default: break; } Chu += Dich; } break; } Chu = Chu.Replace(" ", " "); Resp += Chu.Replace("mươi một", "mươi mốt"); } } } } return(Resp.Substring(0, 1).ToUpper() + Resp.Substring(1) + "./."); }