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);
        }
示例#2
0
        protected void gridHangHoa_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            data = new dataHangHoa();
            string    MaHang = e.NewValues["MaHang"].ToString();
            DataTable dd     = data.KiemTraHangHoa(MaHang);

            if (dd.Rows.Count == 0)
            {
                string IDNhomHang    = e.NewValues["IDNhomHang"].ToString();
                string TenHangHoa    = e.NewValues["TenHangHoa"].ToString();
                string IDDonViTinhLe = e.NewValues["IDDonViTinhLe"].ToString();
                string IDDonViTinhSi = e.NewValues["IDDonViTinhSi"].ToString();
                double GiaMua        = Double.Parse(e.NewValues["GiaMua"].ToString());
                double GiaBan        = Double.Parse(e.NewValues["GiaBan"].ToString());
                double DoDay         = Double.Parse(e.NewValues["DoDay"].ToString());
                double ChieuDai      = Double.Parse(e.NewValues["ChieuDai"].ToString());
                string GhiChu        = e.NewValues["GhiChu"] != null ? e.NewValues["GhiChu"].ToString() : "";
                object IDHangHoa     = data.ThemHangHoa(IDNhomHang, MaHang, TenHangHoa, IDDonViTinhLe, IDDonViTinhSi, GiaMua, GiaBan, GhiChu, DoDay.ToString(), ChieuDai.ToString());
                if (IDHangHoa != null)
                {
                    //thêm vào tồn kho
                    DataTable dta = data.LayDanhSachCuaHang();
                    for (int i = 0; i < dta.Rows.Count; i++)
                    {
                        DataRow dr    = dta.Rows[i];
                        int     IDKho = Int32.Parse(dr["ID"].ToString());
                        data.ThemHangVaoTonKho(IDKho, (int)IDHangHoa, 0);
                    }

                    //thêm vào all bảng giá
                    dtBangGia bg  = new dtBangGia();
                    DataTable dbt = bg.DanhSach();
                    foreach (DataRow dr in dbt.Rows)
                    {
                        string IDBangGia = dr["ID"].ToString();
                        bg.ThemIDHangHoaVaoChiTietGia(IDHangHoa, IDBangGia, GiaBan.ToString());
                    }
                }
                e.Cancel = true;
                gridHangHoa.CancelEdit();
                LoadGrid(cmbSoLuongXem.Value.ToString());
            }
            else
            {
                Response.Write("<script language='JavaScript'> alert('Mã hàng đã tồn tại.'); </script>");
            }
        }
示例#3
0
 private void LoadGrid()
 {
     data = new dtBangGia();
     gridBangGia.DataSource = data.DanhSach(Session["IDChiNhanh"].ToString());
     gridBangGia.DataBind();
 }
示例#4
0
 private void LoadGrid()
 {
     data = new dtBangGia();
     gridBangGia.DataSource = data.DanhSach();
     gridBangGia.DataBind();
 }