private void RefreshThongTinMaDonVi(string maDonVi) { _flag2 = false; txtMaSoThue.Text = string.Empty; txtAddress.Text = string.Empty; txtSoTaiKhoan.Text = string.Empty; cboTenDonVi.Text = string.Empty; if (cboMaDonVi.Text.Trim() != string.Empty) { Result result = ThongTinKhachHangBus.GetThongTinMaDonVi(maDonVi); if (result.IsOK) { ThongTinKhachHang ttkh = result.QueryResult as ThongTinKhachHang; if (ttkh == null) { _flag2 = true; return; } cboTenDonVi.Text = ttkh.TenDonVi; txtMaSoThue.Text = ttkh.MaSoThue; txtAddress.Text = ttkh.DiaChi; txtSoTaiKhoan.Text = ttkh.SoTaiKhoan; cboHinhThucThanhToan.SelectedIndex = ttkh.HinhThucThanhToan.Value; } else { MsgBox.Show(this.Text, result.GetErrorAsString("ThongTinKhachHangBus.GetThongTinMaDonVi"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThongTinKhachHangBus.GetThongTinMaDonVi")); } } _flag2 = true; }
public JsonResult Login(FormCollection data) { String email = data["email"]; String password = data["password"]; DBIO database = new DBIO(); JsonResult json = new JsonResult(); ThongTinKhachHang ttkh = new ThongTinKhachHang(); ttkh = database.CheckLogin(email, password); if (ttkh == null) { json.Data = new { status = "er", }; return(Json(json, JsonRequestBehavior.AllowGet)); } Session["user"] = ttkh; Session.Timeout = 5; // thời gian time out là 5 phút json.Data = new { status = "OK", name = ttkh.Ten_Khanh_Hang, phone = ttkh.Phone, email = ttkh.Email, adress = ttkh.Adress }; return(Json(json, JsonRequestBehavior.AllowGet)); }
private void txt_MaKhach_TextChanged(object sender, EventArgs e) { try{ khachHang = (from tk in db.TAIKHOAN join kh in db.KHACHHANG on tk.MATAIKHOAN equals kh.MATAIKHOAN where tk.SDT == txt_MaKhach.Text select new ThongTinKhachHang { maKhach = kh.MAKH, ten = tk.TEN, diaChi = tk.DIACHI, soDienThoai = tk.SDT }).Single(); } catch (Exception ex) { } if (txtMakhach == null) { khachHang = null; } if (khachHang != null) { txtLoaiKhach.Text = "Thành viên"; txtMakhach.Text = khachHang.maKhach.ToString(); txtTenKhach.Text = khachHang.ten; txtDiaChi.Text = khachHang.diaChi; txtSoDienThoai.Text = khachHang.soDienThoai; } else { txtLoaiKhach.Text = "Khách chơi qua đường"; txtMakhach.Text = ""; txtTenKhach.Text = ""; txtDiaChi.Text = ""; txtSoDienThoai.Text = ""; } }
public ActionResult SuaVe(ThongTinKhachHang ThongTin) { try { string ticketcode = ThongTin.ticketcode; var connection = new AirLineDbContext(); string passengercode = connection.KhachHang_ChuyenBay.Find(ticketcode).MaKhachHang; var ticket = connection.KhachHangs.Find(passengercode); if (ticket == null) { return(HttpNotFound()); } else { ticket.HoTenKhachHang = ThongTin.fullname; ticket.KhuVuc = ThongTin.country; ticket.DienThoai = ThongTin.phone; ticket.Email = ThongTin.email; ticket.Diachi = ThongTin.address; connection.SaveChanges(); return(View("Success", TempData["notice"] = "Sửa vé thành công!")); } } catch { return(View("Success", TempData["notice"] = "Đã có lỗi xảy ra!")); } }
public List <ThongTinKhachHang> timTaiKhoan(string key) { List <ThongTinKhachHang> lst = null; long maInput; if (long.TryParse(key, out maInput) == true) { // nếu là số if (searchNhanVienTheoMa(maInput) != null) { lst = new List <ThongTinKhachHang>(); ThongTinKhachHang tt = searchNhanVienTheoMa(maInput); lst.Add(tt); } if (searchKhachHangTheoMa(maInput) != null) { if (lst == null) { lst = new List <ThongTinKhachHang>(); } ThongTinKhachHang tt = searchKhachHangTheoMa(maInput); lst.Add(tt); } return(lst); } else { //Là từ khóa giống tên lst = searchTaiKhoanTheoKey(key); } return(lst); }
public static Result GetThongTinKhachHang(string thongTinKhachHangGUID) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); ThongTinKhachHang ttkh = db.ThongTinKhachHangs.FirstOrDefault(t => t.ThongTinKhachHangGUID.ToString().ToLower() == thongTinKhachHangGUID.ToLower()); result.QueryResult = ttkh; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public void xoaKH(String _makh) { ThongTinKhachHang xoakh = qlbmp.ThongTinKhachHangs.Where(kh => kh.MaKhachHang == _makh).FirstOrDefault(); qlbmp.ThongTinKhachHangs.DeleteOnSubmit(xoakh); qlbmp.SubmitChanges(); }
public ActionResult DeleteConfirmed(int id) { ThongTinKhachHang thongTinKhachHang = db.ThongTinKhachHangs.Find(id); db.ThongTinKhachHangs.Remove(thongTinKhachHang); db.SaveChanges(); return(RedirectToAction("Index")); }
private void button4_Click(object sender, EventArgs e) { khachHang = null; txtLoaiKhach.Text = "Khách chơi qua đường"; txtMakhach.Text = ""; txtTenKhach.Text = ""; txtDiaChi.Text = ""; txtSoDienThoai.Text = ""; }
public static Result InsertThongTinKhachHang(ThongTinKhachHang ttkh) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); using (TransactionScope t = new TransactionScope(TransactionScopeOption.RequiresNew)) { ThongTinKhachHang thongTinKhachHang = (from tt in db.ThongTinKhachHangs where tt.TenKhachHang.Trim().ToLower() == ttkh.TenKhachHang.Trim().ToLower() && tt.MaDonVi.Trim().ToLower() == ttkh.MaDonVi.Trim().ToLower() //tt.TenDonVi.Trim().ToLower() == ttkh.TenDonVi.Trim().ToLower() && //tt.DiaChi.Trim().ToLower() == ttkh.DiaChi.Trim().ToLower() select tt).FirstOrDefault(); if (thongTinKhachHang == null) { ttkh.ThongTinKhachHangGUID = Guid.NewGuid(); db.ThongTinKhachHangs.InsertOnSubmit(ttkh); } else { //thongTinKhachHang.MaDonVi = ttkh.MaDonVi; //thongTinKhachHang.TenDonVi = ttkh.TenDonVi; //thongTinKhachHang.MaSoThue = ttkh.MaSoThue; //thongTinKhachHang.DiaChi = ttkh.DiaChi; thongTinKhachHang.SoTaiKhoan = ttkh.SoTaiKhoan; thongTinKhachHang.HinhThucThanhToan = ttkh.HinhThucThanhToan; } db.SubmitChanges(); t.Complete(); } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
// // GET: /User/ public ActionResult Index() { if (Session["user"] != null) { ThongTinKhachHang ttkh = (ThongTinKhachHang)Session["user"]; return(View(ttkh)); } return(View()); }
public ActionResult Edit([Bind(Include = "ID,TenKhachHang,DiaChi,SoDienThoai")] ThongTinKhachHang thongTinKhachHang) { if (ModelState.IsValid) { db.Entry(thongTinKhachHang).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(thongTinKhachHang)); }
public static Result GetThongTinDonVi(string tenDonVi) { Result result = new Result(); MMOverride db = null; try { if (tenDonVi == null) { tenDonVi = string.Empty; } db = new MMOverride(); ThongTinKhachHang thongTinKhachHang = null; Company company = db.Companies.FirstOrDefault(t => t.TenCty.Trim().ToLower() == tenDonVi.Trim().ToLower() && t.Status == (byte)Status.Actived); if (company != null) { thongTinKhachHang = new ThongTinKhachHang(); thongTinKhachHang.MaDonVi = company.MaCty; thongTinKhachHang.TenDonVi = company.TenCty; thongTinKhachHang.DiaChi = company.DiaChi; thongTinKhachHang.MaSoThue = company.MaSoThue; thongTinKhachHang.HinhThucThanhToan = 0; ThongTinKhachHang ttkh = db.ThongTinKhachHangs.FirstOrDefault(t => t.TenDonVi.Trim().ToLower() == tenDonVi.Trim().ToLower()); if (ttkh != null) { thongTinKhachHang.HinhThucThanhToan = ttkh.HinhThucThanhToan; thongTinKhachHang.SoTaiKhoan = ttkh.SoTaiKhoan; } } result.QueryResult = thongTinKhachHang; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public ActionResult Create([Bind(Include = "ID,TenKhachHang,DiaChi,SoDienThoai")] ThongTinKhachHang thongTinKhachHang) { if (ModelState.IsValid) { db.ThongTinKhachHangs.Add(thongTinKhachHang); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(thongTinKhachHang)); }
public void themKH(String _makh, String _tenkh, String _diachi, String _sdt, int _tichdiem, String _manhomnd) { ThongTinKhachHang kh = new ThongTinKhachHang(); kh.MaKhachHang = _makh; kh.TenKhachHang = _tenkh; kh.DiaChi = _diachi; kh.SoDienThoai = _sdt; kh.TichDiem = _tichdiem; kh.MaNhomNguoiDung = _manhomnd; qlbmp.ThongTinKhachHangs.InsertOnSubmit(kh); qlbmp.SubmitChanges(); }
public ActionResult Create(ThongTinKhachHang ttkh) { try { // TODO: Add insert logic here thongtinkh.ThemTTKH(ttkh); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: ThongTinKhachHangs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ThongTinKhachHang thongTinKhachHang = db.ThongTinKhachHangs.Find(id); if (thongTinKhachHang == null) { return(HttpNotFound()); } return(View(thongTinKhachHang)); }
public JsonResult SignIn(FormCollection data) { ThongTinKhachHang ttkh = new ThongTinKhachHang(); JsonResult js = new JsonResult(); DBIO provider = new DBIO(); try { ttkh.Ten_Khanh_Hang = data["name"]; ttkh.Email = data["email"]; ttkh.Phone = data["phone"]; ttkh.Password = data["password"]; ttkh.Adress = data["adress"]; } catch (Exception e) { js.Data = new { status = "er", message = e }; return(Json(js, JsonRequestBehavior.AllowGet)); } if (provider.CheckUserExit(ttkh.Email) == 1) { js.Data = new { status = "exit", }; return(Json(js, JsonRequestBehavior.AllowGet)); } provider.InsertNewUser(ttkh); provider.SaveChange(); //provider.InsertUserByQuery(ttkh.Ten_Khanh_Hang, ttkh.Email, ttkh.Phone, ttkh.Password, ttkh.Adress); Session["user"] = ttkh; Session.Timeout = 5; js.Data = new { status = "OK", name = ttkh.Ten_Khanh_Hang, email = ttkh.Email, phone = ttkh.Phone, pass = ttkh.Password, diachi = ttkh.Adress }; return(Json(js, JsonRequestBehavior.AllowGet)); }
public ActionResult LayThongTinKhachHang(string ip_str_id_khach_hang) { try { BKI_CRMEntities v_model = new BKI_CRMEntities(); DM_KHACH_HANG v_dm_kh = new DM_KHACH_HANG(); ThongTinKhachHang v_dm_khach_hang = new ThongTinKhachHang(); v_dm_kh = v_model.DM_KHACH_HANG.Where(x => x.ID == new Guid(ip_str_id_khach_hang)).First(); v_dm_khach_hang = v_dm_kh.CopyAs <ThongTinKhachHang>(); return(Json(v_dm_khach_hang, JsonRequestBehavior.AllowGet)); } catch (System.Exception v_e) { v_e.Log(); return(Json(false)); } }
public ThongTinKhachHang ThongTinDonHang(int id) { var result = new ThongTinKhachHang(); using (var db = _connection.GetConnection()) { result = db.QuerySingle <ThongTinKhachHang>("SELECT * FROM info.ThongTinKhachHang WHERE Id=@Id;", new { Id = id }); result.SanPhams = db .Query <SanPhamMua >("SELECT Id,TenSanPham,SoLuong FROM info.SanPhamMua WHERE ThongTinKhachHangId=@ThongTinKhachHangId;", new { ThongTinKhachHangId = id }) .ToList(); } return(result); }
public void Them_DonHang(ThongTinKhachHang order) { using (var db = _connection.GetConnection()) { // insert ThongTinKhachHang db.Execute("UPDATE info.ThongTinKhachHang SET TenKhachHang=@TenKhachHang,DiaChi=@DiaChi,DienThoai=@DienThoai,TrangThai=@TrangThai,NgayTao=@NgayTao,IsDeleted=@IsDeleted, IsInit=@IsInit WHERE Id=@Id;", new { order.Id, order.TenKhachHang, order.DiaChi, order.DienThoai, order.TrangThai, order.NgayTao, order.IsDeleted, order.IsInit }); // insert SanPhamMua db.Execute("INSERT INTO info.SanPhamMua(ThongTinKhachHangId,TenSanPham,SoLuong) VALUES(@ThongTinKhachHangId,@TenSanPham,@SoLuong);", order.SanPhams.Select(p => new { ThongTinKhachHangId = order.Id, p.TenSanPham, p.SoLuong })); } // producer publish message _producer.PublishMessage(new Message_Customer { Id = order.Id, //ThongTinKhachHangId CustomerAddress = order.DiaChi, PhoneNumber = order.DienThoai, CustomerName = order.TenKhachHang, Status = Status.Da_Thanh_Toan }); }
ThongTinKhachHang searchNhanVienTheoMa(long ma) { ThongTinKhachHang tt = null; try { tt = (from tk in db.TAIKHOAN join nv in db.NHANVIEN on tk.MATAIKHOAN equals nv.MATAIKHOAN where nv.MANHANVIEN == ma select new ThongTinKhachHang { maKhach = nv.MANHANVIEN, maTaiKhoan = tk.MATAIKHOAN, ten = tk.TEN, diaChi = tk.DIACHI, soDienThoai = tk.SDT, isNhanVien = true, gioiTinh = (bool)tk.GIOITINH, ngaySinh = (DateTime)tk.NGAYSINH }).Single(); } catch (Exception ex) { } return(tt); }
ThongTinKhachHang searchKhachHangTheoMa(long ma) { ThongTinKhachHang tt = null; try { tt = (from tk in db.TAIKHOAN join kh in db.KHACHHANG on tk.MATAIKHOAN equals kh.MATAIKHOAN where kh.MAKH == ma select new ThongTinKhachHang { maKhach = kh.MAKH, maTaiKhoan = tk.MATAIKHOAN, ten = tk.TEN, diaChi = tk.DIACHI, soDienThoai = tk.SDT, isNhanVien = false, gioiTinh = (bool)tk.GIOITINH, ngaySinh = (DateTime)tk.NGAYSINH }).Single(); } catch (Exception ex) { } return(tt); }
// insert người mới đăng kí cách 1 public void InsertNewUser(ThongTinKhachHang ttkh) { bosstable.ThongTinKhachHangs.Add(ttkh); }
List <ThongTinKhachHang> searchTaiKhoanTheoKey(string key) { List <TAIKHOAN> lst = null; try { lst = (from c in db.TAIKHOAN where c.TEN.Contains(key) select c).ToList(); } catch (Exception ex) { } List <ThongTinKhachHang> resLst = null; if (lst != null) { resLst = new List <ThongTinKhachHang>(); foreach (TAIKHOAN item in lst) { bool isNhanVien = (bool)(from c in db.TAIKHOAN where c.MATAIKHOAN == item.MATAIKHOAN select c.ISNHANVIEN).Single(); if (isNhanVien == true) { // là nhân viên join với bản nhân viên để lấy mã ThongTinKhachHang tt = (from c in db.TAIKHOAN join nv in db.NHANVIEN on c.MATAIKHOAN equals nv.MATAIKHOAN select new ThongTinKhachHang { maKhach = nv.MANHANVIEN, maTaiKhoan = c.MATAIKHOAN, ten = c.TEN, diaChi = c.DIACHI, gioiTinh = (bool)c.GIOITINH, isNhanVien = true, ngaySinh = (DateTime)c.NGAYSINH, soDienThoai = c.SDT }).Single(); resLst.Add(tt); } else { //là khách hàng join với bảng khách hàng để lấy mã ThongTinKhachHang tt = (from c in db.TAIKHOAN join kh in db.KHACHHANG on c.MATAIKHOAN equals kh.MATAIKHOAN select new ThongTinKhachHang { maKhach = kh.MAKH, maTaiKhoan = c.MATAIKHOAN, ten = c.TEN, diaChi = c.DIACHI, gioiTinh = (bool)c.GIOITINH, isNhanVien = false, ngaySinh = (DateTime)c.NGAYSINH, soDienThoai = c.SDT }).Single(); resLst.Add(tt); } } } return(resLst); }
private bool ExportInvoice() { try { if (!CheckInfo()) { return(false); } HoaDonXetNghiem invoice = new HoaDonXetNghiem(); invoice.SoHoaDon = _invoiceCode; invoice.NgayXuatHoaDon = dtpkNgay.Value; invoice.TenNguoiMuaHang = cboTenNguoiMuaHang.Text; invoice.DiaChi = txtAddress.Text; invoice.TenDonVi = cboTenDonVi.Text; invoice.MaDonVi = cboMaDonVi.Text; invoice.MaSoThue = txtMaSoThue.Text; invoice.SoTaiKhoan = txtSoTaiKhoan.Text; invoice.HinhThucThanhToan = (byte)cboHinhThucThanhToan.SelectedIndex; invoice.VAT = (double)numVAT.Value; invoice.CreatedDate = DateTime.Now; invoice.CreatedBy = Guid.Parse(Global.UserGUID); invoice.Status = (byte)Status.Actived; invoice.ChuaThuTien = !chkDaThuTien.Checked; invoice.MauSo = Global.MauSoXetNghiemSauCung; invoice.KiHieu = Global.KiHieuXetNghiemSauCung; invoice.HinhThucNhanHoaDon = raKhachTuLay.Checked ? "Khách tự lấy" : "Gởi qua bưu điện"; invoice.Notes = txtGhiChu.Text; List <ChiTietHoaDonXetNghiem> addedDetails = new List <ChiTietHoaDonXetNghiem>(); for (int i = 0; i < dgDetail.RowCount - 1; i++) { DataGridViewRow row = dgDetail.Rows[i]; ChiTietHoaDonXetNghiem detail = new ChiTietHoaDonXetNghiem(); detail.CreatedDate = DateTime.Now; detail.CreatedBy = Guid.Parse(Global.UserGUID); detail.TenHangHoa = row.Cells["TenHangHoa"].Value.ToString(); //if (row.Cells["DonViTinh"].Value != null) // detail.DonViTinh = row.Cells["DonViTinh"].Value.ToString(); //else detail.DonViTinh = "Lần"; int soLuong = 1; //if (row.Cells["SoLuong"].Value != null && row.Cells["SoLuong"].Value != DBNull.Value) // soLuong = Convert.ToInt32(row.Cells["SoLuong"].Value); detail.SoLuong = soLuong; //int donGia = 0; //if (row.Cells["DonGia"].Value != null && row.Cells["DonGia"].Value != DBNull.Value) // donGia = Convert.ToInt32(row.Cells["DonGia"].Value); //detail.DonGia = donGia; int thanhTien = 0; if (row.Cells["ThanhTien"].Value != null && row.Cells["ThanhTien"].Value != DBNull.Value) { thanhTien = Convert.ToInt32(row.Cells["ThanhTien"].Value); } detail.ThanhTien = thanhTien; detail.DonGia = thanhTien; addedDetails.Add(detail); } Result result = HoaDonXetNghiemBus.InsertHoaDonXetNghiem(invoice, addedDetails); if (result.IsOK) { //Insert thông tin khách hàng ThongTinKhachHang thongTinKhachHang = new ThongTinKhachHang(); thongTinKhachHang.TenKhachHang = invoice.TenNguoiMuaHang; //thongTinKhachHang.TenDonVi = invoice.TenDonVi; thongTinKhachHang.MaDonVi = invoice.MaDonVi; //thongTinKhachHang.MaSoThue = invoice.MaSoThue; //thongTinKhachHang.DiaChi = invoice.DiaChi; thongTinKhachHang.SoTaiKhoan = invoice.SoTaiKhoan; thongTinKhachHang.HinhThucThanhToan = invoice.HinhThucThanhToan; result = ThongTinKhachHangBus.InsertThongTinKhachHang(thongTinKhachHang); if (!result.IsOK) { MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThongTinKhachHangBus.InsertThongTinKhachHang"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("ThongTinKhachHangBus.InsertThongTinKhachHang")); } _hoaDonXetNghiem = invoice; if (!_isPrinted) { return(true); } OnPrint(invoice.HoaDonXetNghiemGUID.ToString()); return(true); } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("HoaDonXetNghiemBus.InsertHoaDonXetNghiem"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("HoaDonXetNghiemBus.InsertHoaDonXetNghiem")); } } catch (Exception ex) { MsgBox.Show(Application.ProductName, ex.Message, IconType.Error); Utility.WriteToTraceLog(ex.Message); } return(false); }