// Function Thêm hóa đơn private void Add() { if (txtMaSim.Text == "") { Print_MessageBox("Chưa chọn mã sim !", "Kết quả"); } else if (sim.checkifLocked(txtMaSim.Text) == false) { Print_MessageBox("SIM không hợp lệ và đã bị khóa ! Hãy chọn SIM khác ! ", "Kết quả"); } else if (txtNgayLapPhieu.Text == "") { Print_MessageBox("Kì sử dụng không hợp lệ !", "Kết quả"); } else if ((Convert.ToDateTime(txtNgayLapPhieu.Text) > DateTime.Now.Date)) { Print_MessageBox("kì sử dụng không hợp lệ !", "Kết quả"); } else { var Id_SIM = txtMaSim.Text; var date_export = new DateTime(Convert.ToDateTime(txtNgayLapPhieu.Text).Year, Convert.ToDateTime(txtNgayLapPhieu.Text).Day, Convert.ToDateTime(txtNgayLapPhieu.Text).Month); var invoice_date = new DateTime(Convert.ToDateTime(txtInvoice_date.Text).Year, Convert.ToDateTime(txtInvoice_date.Text).Day, Convert.ToDateTime(txtInvoice_date.Text).Month); var date_cut = invoice_date.AddMonths(1); var date_endUse = date_export.AddMonths(1); var TotalFare = detail.GetFare(Id_SIM, date_export, date_endUse); // Gửi email để thông báo string id_customer = sim.getIDcustomer_in_Sim(Id_SIM); string email = customer.getEmail_in_Customer(id_customer); string name_customer = customer.getName_in_Customer(id_customer); string phone = sim.getPhone_in_Customer(id_customer); string address = customer.getAddress_in_Customer(id_customer); bill.SendBillByEmail(email, name_customer, phone, address, Id_SIM, date_export, invoice_date, date_cut, 50000, TotalFare + Convert.ToInt32(txtPhiThueBao.Text)); // Lưu vào database var result = bill.Create(Id_SIM, date_export, invoice_date, date_cut, Convert.ToInt32(txtPhiThueBao.Text), TotalFare + Convert.ToInt32(txtPhiThueBao.Text), false); Print_MessageBox(result, "Thông báo thêm"); } }
private void btnTBDinhChi_Click(object sender, EventArgs e) { var Id_SIM = txtMaSim.Text; var date_export = new DateTime(Convert.ToDateTime(txtNgayLapPhieu.Text).Year, Convert.ToDateTime(txtNgayLapPhieu.Text).Day, Convert.ToDateTime(txtNgayLapPhieu.Text).Month); var invoice_date = new DateTime(Convert.ToDateTime(txtInvoiceDate.Text).Year, Convert.ToDateTime(txtInvoiceDate.Text).Day, Convert.ToDateTime(txtInvoiceDate.Text).Month); var date_cut = invoice_date.AddMonths(1); var date_endUse = date_export.AddMonths(1); var TotalFare = detailbll.GetFare(Id_SIM, date_export, date_endUse); // Gửi email để thông báo string id_customer = simbll.getIDcustomer_in_Sim(Id_SIM); string email = customer.getEmail_in_Customer(id_customer); string name_customer = customer.getName_in_Customer(id_customer); string phone = simbll.getPhone_in_Customer(id_customer); string address = customer.getAddress_in_Customer(id_customer); billbll.SendBillByEmail1(email, name_customer, phone, address, Id_SIM, date_export, invoice_date, date_cut, 50000, TotalFare + Convert.ToInt32(txtPhiThueBao.Text)); // Lưu vào database Print_MessageBox("Gửi mail thông báo việc đình chỉ sim thành công!", "Thông báo gửi"); }