protected void gridDanhSach_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { string IDChiNhanh = e.NewValues["IDChiNhanh"].ToString(); string MaKhuVuc = dtKhuVuc.Dem_Max(IDChiNhanh); string TenKhuVuc = e.NewValues["TenKhuVuc"].ToString(); string TyLe = e.NewValues["TyLe"].ToString(); string GhiChu = e.NewValues["GhiChu"] == null ? "" : e.NewValues["GhiChu"].ToString(); data = new dtKhuVuc(); data.Them(MaKhuVuc, TenKhuVuc, TyLe, IDChiNhanh, GhiChu); e.Cancel = true; gridDanhSach.CancelEdit(); LoadGrid(); }
protected void gridDanhSach_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { string IDChiNhanh = e.NewValues["IDChiNhanh"].ToString(); string KyHieu = e.NewValues["KyHieu"].ToString(); string MaKhuVuc = "1"; string TenKhuVuc = e.NewValues["TenKhuVuc"].ToString(); string IDBangGia = e.NewValues["IDBangGia"].ToString(); string GhiChu = e.NewValues["GhiChu"] == null ? "" : e.NewValues["GhiChu"].ToString(); data = new dtKhuVuc(); data.Them(MaKhuVuc, TenKhuVuc, "0", IDChiNhanh, GhiChu, KyHieu, IDBangGia); e.Cancel = true; gridDanhSach.CancelEdit(); LoadGrid(); dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Quản lý khu vực", "Thêm khu vực: " + TenKhuVuc); }
protected void gridChiNhanh_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { string MaChiNhanh = dtChiNhanh.Dem_Max(); string TenChiNhanh = e.NewValues["TenChiNhanh"].ToString(); string DienThoai = e.NewValues["DienThoai"] == null ? "" : e.NewValues["DienThoai"].ToString(); string Email = e.NewValues["Email"] == null ? "" : e.NewValues["Email"].ToString(); string DiaChi = e.NewValues["DiaChi"] == null ? "" : e.NewValues["DiaChi"].ToString(); DateTime NgayMo = DateTime.Parse(e.NewValues["NgayMo"].ToString()); string DuLieuMau = e.NewValues["DuLieuMau"] == null ? "0" : "1"; string Key = RandomString(5) + "-" + RandomString(5) + "-" + RandomString(5) + "-" + RandomString(5) + "-" + RandomString(5); data = new dtChiNhanh(); object ID = data.ThemChiNhanh(MaChiNhanh, TenChiNhanh, DienThoai, DiaChi, NgayMo, DuLieuMau, Key, Email); if (ID != null) { // tạo key kích hoạt data = new dtChiNhanh(); data.ThemKeyKichHoat(Key, ID.ToString()); // Tạo bảng giá dtBangGia dtBangGia = new dtBangGia(); object IDBangGia = dtBangGia.ThemMoi("Bảng Giá Thường", ID.ToString()); // tạo khu vực dtKhuVuc dtKhuVuc = new dtKhuVuc(); object IDKhuVuc = dtKhuVuc.Them("", "Khu A", "0", ID.ToString(), TenChiNhanh, "A", IDBangGia.ToString()); //tạo tài khoản dtQuanTriNguoiDung dtNguoiDung = new dtQuanTriNguoiDung(); if (dtQuanTriNguoiDung.KiemTraNguoiDung(DienThoai.Trim()) != -1) { throw new Exception("Lỗi: Tên đăng nhập đã tồn tại"); } else { dtNguoiDung.ThemNguoiDung(dtQuanTriNguoiDung.Dem_Max(), "Quản trị", DienThoai, 1, DienThoai, dtSetting.GetSHA1HashData(DienThoai), Email, ID.ToString()); dtNguoiDung.ThemNguoiDung(dtQuanTriNguoiDung.Dem_Max(), "Thu ngân", "BH." + DienThoai, 2, DienThoai, dtSetting.GetSHA1HashData(DienThoai), Email, ID.ToString()); } if (DuLieuMau == "1") { //tạo dữ liệu mẫu, lấy Chi Nhánh 1 ra làm //thêm đVT dtDonViTinh dtDVT = new dtDonViTinh(); DataTable tbdvt = dtDVT.LayDanhSachDonViTinh("1"); foreach (DataRow dr in tbdvt.Rows) { dtDVT.ThemDonViTinh(dr["TenDonViTinh"].ToString(), ID.ToString()); } //Thêm nhóm hàng dtNhomHangHoa dtNhomHang = new dtNhomHangHoa(); DataTable tbNhomHang = dtNhomHang.DanhSach("1"); foreach (DataRow dr1 in tbNhomHang.Rows) { object IDNhomHangMoi = dtNhomHang.Them(dtNhomHangHoa.Dem_Max(), dr1["TenNhom"].ToString(), "", ID.ToString()); //Thêm hàng hóa dtHangHoa dtHH = new dtHangHoa(); DataTable tbHH = dtHH.DanhSachHangHoa_IDnhomHang(dr1["ID"].ToString(), "1"); foreach (DataRow dr in tbHH.Rows) { string IDDVTCU = dr["IDDonViTinh"].ToString(); object IDHH = dtHH.ThemHangHoa(dtHangHoa.Dem_Max(), dr["TenHangHoa"].ToString(), dr["GiaBan"].ToString(), dtDonViTinh.LayIDDVT_Moi(IDDVTCU, ID.ToString()), IDNhomHangMoi.ToString(), dr["GhiChu"].ToString(), ID.ToString()); if (IDHH != null) { //thêm vào bảng giá dtBangGia bg = new dtBangGia(); bg.ThemIDHangHoaVaoChiTietGia(IDHH.ToString(), IDBangGia, dr["GiaBan"].ToString(), ID.ToString()); } } } //thêm 30 bàn mẫu for (int i = 1; i <= 30; i++) { dtBan dtB = new dtBan(); dtB.Them("", "A - " + i, IDKhuVuc.ToString(), ID.ToString()); } } } e.Cancel = true; gridChiNhanh.CancelEdit(); LoadGrid(); dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Chi nhánh", "Thêm chi nhánh: " + TenChiNhanh); }