private void iMaSoThue_TextChanged(object sender, EventArgs e) { if (!XuLyDuLieu.IsNumeric(iMaSoThue.Text)) { iMaSoThue.Text = string.Empty; } }
public static void KiemTra(List <KiemTra> lstThongBao, DXValidationProvider dx) { foreach (KiemTra ctl in lstThongBao) { if (ctl._ChoQuaThang) { dx.SetValidationRule(ctl._Control, new TextValidationRule(string.Empty, true)); } else if (ctl._Mail) { ctl._Control.Text = ctl._Control.Text ?? string.Empty; string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; Regex re = new Regex(strRegex); if (ctl._Control.Text.Length > 9 && re.IsMatch(ctl._Control.Text.TrimEnd().TrimStart())) { dx.SetValidationRule(ctl._Control, new TextValidationRule(ctl._ThongBao2, ctl._ChoQua)); } else { dx.SetValidationRule(ctl._Control, new TextValidationRule("Mail không hợp lệ", false)); } } else if (ctl._SDT) { if (ctl._Control.Text.Length > 9) { if (XuLyDuLieu.IsNumeric(ctl._Control.Text.Replace("+", string.Empty))) { dx.SetValidationRule(ctl._Control, new TextValidationRule(ctl._ThongBao2, ctl._ChoQua)); } else { dx.SetValidationRule(ctl._Control, new TextValidationRule("Số điện thoại không hợp lệ", false)); } } else { dx.SetValidationRule(ctl._Control, new TextValidationRule("Ít nhất 10 kí tự", false)); } } else if (ctl._KiemTraChuoi) { int Te = ctl._Control.Text.Replace(" ", string.Empty).Replace("\r\n", "").Length; if (Te > ctl._Tu - 1 && ctl._Den + 1 > Te) { dx.SetValidationRule(ctl._Control, new TextValidationRule(ctl._ThongBao2, ctl._ChoQua)); } else { dx.SetValidationRule(ctl._Control, new TextValidationRule(string.Format("Nhập từ {0} đến {1}", ctl._Tu, ctl._Den), false)); } } } }
private void rDaBaoGia_KeyDown(object sender, KeyEventArgs e) { TextEdit z = (sender as TextEdit); string a = z.Text; if ((e.KeyCode == Keys.Enter) && Text.Length > 4) { if (XuLyDuLieu.IsNumeric(a)) { z.Text = string.Empty; hoaDonD.CapNhatTrangThai(z.Properties.Name.Substring(1), a.Replace(" ", string.Empty)); DuLieu(); } } }
private void wQH_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (wQH.ReadyState == WebBrowserReadyState.Complete && !wQH.IsBusy) { Thread.Sleep(2000); HtmlElement head1 = wQH.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = wQH.Document.CreateElement("script"); IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement; if (wQH.Url.AbsolutePath.Contains("/login")) // Trang login { wQH.Document.GetElementById("login-agency-code").SetAttribute("value", _NCCO.MaHang); wQH.Document.GetElementById("login-agency-id").SetAttribute("value", _NCCO.TaiKhoan); wQH.Document.GetElementById("login-password").SetAttribute("value", _NCCO.MatKhau); element.text = @"function doPost() {submitLoginForm('en_US');}"; head1.AppendChild(scriptEl); wQH.Document.InvokeScript("doPost"); } else if (wQH.Url.AbsolutePath.Contains("/agent")) { switch (step) { case 0: element.text = @"function doPost() {createInvoice(event);}"; head1.AppendChild(scriptEl); wQH.Document.InvokeScript("doPost"); break; case 1: wQH.Document.GetElementById("ir-start-date").SetAttribute("value", ((DateTime)eDate1.EditValue).ToString("dd/MM/yyyy")); wQH.Document.GetElementById("ir-end-date").SetAttribute("value", ((DateTime)eDate2.EditValue).ToString("dd/MM/yyyy")); element.text = @"function doPost() {doInvoice('/reservation','vi',true);}"; head1.AppendChild(scriptEl); wQH.Document.InvokeScript("doPost"); break; case 2: if (((DateTime)eDate1.EditValue).Subtract(DateTime.Now).Days == 0) { element.text = @"function doPost() {viewdetails('0', 'VND', 'AG', '" + _NCCO.MaHang + "');}"; head1.AppendChild(scriptEl); wQH.Document.InvokeScript("doPost"); step++; } else { wQH.Document.GetElementById("invoicedetails").InvokeMember("click"); } break; case 4: HtmlElementCollection eleth = wQH.Document.GetElementsByTagName("th"); if (DataVJ.Columns.Count != 25) { for (int u = 0; u < eleth.Count; u++) { DataVJ.Columns.Add(eleth[u].InnerText, (new int[] { 9, 10, 11, 13, 14, 15 }.Contains(u)) ? typeof(double) : typeof(string)); } } HtmlElementCollection ele = wQH.Document.GetElementsByTagName("tr"); List <O_GIAODICH> lst1 = new List <O_GIAODICH>(); foreach (HtmlElement eles in ele) { HtmlElementCollection elez = eles.GetElementsByTagName("td"); if (elez.Count == 0) { continue; } List <string> lststr1 = new List <string>(); for (int u = 0; u < elez.Count; u++) { if (elez[u].InnerText != null) { if (XuLyDuLieu.IsNumeric(elez[u].InnerText.Replace(",", string.Empty))) { lststr1.Add(elez[u].InnerText.Replace(",", string.Empty)); } else { lststr1.Add(elez[u].InnerText); } } else { if (new int[] { 9, 10, 11, 13, 14, 15 }.Contains(u)) { lststr1.Add("0"); } else { lststr1.Add(elez[u].InnerText); } } } if (lststr1.Count == DataVJ.Columns.Count) { DataVJ.Rows.Add(lststr1.ToArray()); } O_GIAODICH gd = new O_GIAODICH(); string[] ten = elez[7].InnerText.Split('/'); gd.TenKhach = ten[1] + " " + ten[0]; gd.MaCho = elez[4].InnerText; if (long.Parse(elez[15].InnerText.Replace(",", string.Empty)) < 0) { gd.HangHoan = XuLyDuLieu.ConvertStringToLong(elez[15].InnerText); } else { gd.GiaNet = XuLyDuLieu.ConvertStringToLong(elez[15].InnerText); } lst1.Add(gd); } GCVTNCC.DataSource = lst1.Where(w => w.GiaNet > 0); GCVHNCC.DataSource = lst1.Where(w => w.HangHoan > 0); if (XuLyGiaoDien.wait.IsSplashFormVisible) { XuLyGiaoDien.wait.CloseWaitForm(); } XtraMessageBox.Show("Lấy dữ liệu thành công", "Thông báo"); wQH.Visible = false; //element.text = @"function doPost() {invoiceDetailExport('xls','/reservation','vi');}"; //head1.AppendChild(scriptEl); //wQH.Document.InvokeScript("doPost"); break; } step++; } } }