protected void gridHangHoa_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { data = new dtHangHoa(); string MaHangHoa = dtHangHoa.Dem_Max(); string TenHangHoa = e.NewValues["TenHangHoa"].ToString(); string GiaBan = e.NewValues["GiaBan"].ToString(); string IDDonViTinh = e.NewValues["IDDonViTinh"].ToString(); string IDNhomHang = e.NewValues["IDNhomHang"].ToString(); string GhiChu = e.NewValues["GhiChu"] == null ? "" : e.NewValues["GhiChu"].ToString(); string IDChiNhanh = Session["IDChiNhanh"].ToString(); object ID = data.ThemHangHoa(MaHangHoa, TenHangHoa, GiaBan, IDDonViTinh, IDNhomHang, GhiChu, IDChiNhanh); if (ID != null) { //thêm vào all bảng giá dtBangGia bg = new dtBangGia(); DataTable dbt = bg.DanhSach(IDChiNhanh); foreach (DataRow dr in dbt.Rows) { string IDBangGia = dr["ID"].ToString(); bg.ThemIDHangHoaVaoChiTietGia(ID.ToString(), IDBangGia, GiaBan, IDChiNhanh); } } e.Cancel = true; gridHangHoa.CancelEdit(); LoadGrid(); dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Quản lý hàng hóa", "Thêm hàng hóa: " + TenHangHoa); }
protected void gridHangHoa_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { data = new dtHangHoa(); string MaHangHoa = e.NewValues["MaHangHoa"].ToString(); string TenHangHoa = e.NewValues["TenHangHoa"].ToString(); string GiaBan = e.NewValues["GiaBan"].ToString(); string IDDonViTinh = e.NewValues["IDDonViTinh"].ToString(); string IDNhomHang = e.NewValues["IDNhomHang"].ToString(); string GhiChu = e.NewValues["GhiChu"] == null ? "" : e.NewValues["GhiChu"].ToString(); data.ThemHangHoa(MaHangHoa, TenHangHoa, GiaBan, IDDonViTinh, IDNhomHang, GhiChu); e.Cancel = true; gridHangHoa.CancelEdit(); LoadGrid(); }
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); }