private void GetDonHangTamFromServer( ) { const string url = "http://kienuit.esy.es/don_hang.php"; var request = (HttpWebRequest)WebRequest.Create(url); var response = (HttpWebResponse)request.GetResponse(); var sr = new StreamReader(response.GetResponseStream()); var result = sr.ReadToEnd(); var customers = result.Split('-').TakeWhile(x => x != ""); if (result == "0 results") { return; } foreach (var customer in customers) { var str = customer.Split('@'); var donHang = new DonHangTamDTO { MaDonHangTam = str [9], NgayDatHang = DateTime.ParseExact(str [10], "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture), TenNguoiBan = str [0], LienHeNguoiBan = str [2], SDTNguoiBan = str [1], SDTNguoiMua = str [8], DiaDiemNhan = str [6], TenNguoiMua = str [7], DiaDiemGiao = str [5], TienThuHo = double.Parse(str [4]), GhiChu = str [3] }; if (DonHangTamBUS.CheckDonHangTam(donHang.MaDonHangTam)) { string url2 = $"http://kienuit.esy.es/xoa_hang.php?Ma={donHang.MaDonHangTam}"; HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create(url2); HttpWebResponse response2 = (HttpWebResponse)request2.GetResponse(); continue; } var mail = new MailMessage("*****@*****.**", "*****@*****.**", "[Đơn hàng chưa xác nhận]" + donHang.MaDonHangTam, $"{donHang.MaDonHangTam}|{donHang.NgayDatHang}|{donHang.TenNguoiBan}|{donHang.LienHeNguoiBan}|{donHang.SDTNguoiBan}|{donHang.SDTNguoiMua}|{donHang.DiaDiemNhan}|{donHang.TenNguoiMua}|{donHang.DiaDiemGiao}|{donHang.TienThuHo}|{donHang.GhiChu}"); var smtp = new SmtpClient() { Host = "smtp.gmail.com", Port = 587, Credentials = new NetworkCredential("*****@*****.**", "binhdinhex769799"), EnableSsl = true }; smtp.Send(mail); DonHangTamBUS.ThemDonHangTam(donHang); string url3 = $"http://kienuit.esy.es/xoa_hang.php?Ma={donHang.MaDonHangTam}"; HttpWebRequest request3 = (HttpWebRequest)WebRequest.Create(url3); HttpWebResponse response3 = (HttpWebResponse)request3.GetResponse(); } }
public DonHangTamThoi(DonHangTamDTO donHang) { MaDonHangTam = donHang.MaDonHangTam; NgayDatHang = donHang.NgayDatHang; TenNguoiBan = donHang.TenNguoiBan; LienHeNguoiBan = donHang.LienHeNguoiBan; SdtNguoiBan = donHang.SDTNguoiBan; SdtNguoiMua = donHang.SDTNguoiMua; DiaDiemNhanHang = donHang.DiaDiemNhan; TenNguoiMua = donHang.TenNguoiMua; DiaDiemGiaoHang = donHang.DiaDiemGiao; TienThuHo = donHang.TienThuHo; GhiChu = donHang.GhiChu; }