Esempio n. 1
0
        private void KhoiTao(string MaNhomHang)
        {
            if (grdvDSMatHang.ColumnCount > 0)
            {
                grdvDSMatHang.Columns.Clear();
                grdvDSMatHang.DataSource = null;
                bindingSource1           = new BindingSource();
            }
            DataTable Bang;

            if (MaNhomHang == "")
            {
                Bang = MatHangBus.LayBang();
            }
            else
            {
                Bang = MatHangBus.LayBang(MaNhomHang);
            }
            DataColumn Cot = new DataColumn();

            Cot.ColumnName = "NgungBan";
            Cot.Caption    = "Ngưng Bán";
            Bang.Columns.Add(Cot);
            foreach (DataRow Dong in Bang.Rows)
            {
                Dong["ThueVAT"] = Double.Parse(Dong["ThueVAT"].ToString()) / 100;
                if (Dong["TrangThai"].ToString().Trim() == "2")
                {
                    Dong["NgungBan"] = "Ngưng bán";
                }
                else
                {
                    Dong["NgungBan"] = "";
                }
            }
            //Bang.Columns["TrangThai"].DataType =
            //Loc thong tin mat hang
            bindingSource1.DataSource = Bang;
            string sql = "";

            if (radioTheoMa.Checked == true)
            {
                sql = " CONVERT([MaMatHang], 'System.String') = '" + txtMatHang.Text.Trim() + "' ";
            }
            else
            {
                sql = " CONVERT([TenMatHang], 'System.String') LIKE '%" + txtMatHang.Text.Trim() + "%' ";
            }
            if (txtMatHang.Text.Trim() != "")
            {
                bindingSource1.Filter = sql;
            }
            grdvDSMatHang.DataSource = bindingSource1;
            AnCotTrenLuoi();
            DinhDangCot();
        }
        private void KhoiTao(string MaNhomHang)
        {
            if (grdvDSMatHang.ColumnCount > 0)
            {
                grdvDSMatHang.Columns.Clear();
                grdvDSMatHang.DataSource = null;
                bindingSource1           = new BindingSource();
            }
            DataTable Bang;

            if (MaNhomHang == "TatCa")
            {
                Bang = MatHangBus.LayBang();
            }
            else
            {
                Bang = MatHangBus.LayBang(MaNhomHang);
            }
            DataColumn Cot = new DataColumn("ThucHien");

            Cot.DefaultValue = "BinhThuong";
            Bang.Columns.Add(Cot);
            foreach (DataRow Dong in Bang.Rows)
            {
                Dong["ThueVAT"] = Double.Parse(Dong["ThueVAT"].ToString()) / 100;
            }
            //Loc thong tin mat hang
            bindingSource1.DataSource = Bang;
            string sql = "";

            if (radioTheoMa.Checked == true)
            {
                sql = " CONVERT([MaMatHang], 'System.String') = '" + txtMatHang.Text.Trim() + "' ";
            }
            else
            {
                sql = " CONVERT([TenMatHang], 'System.String') LIKE '%" + txtMatHang.Text.Trim() + "%' ";
            }
            if (txtMatHang.Text.Trim() != "")
            {
                bindingSource1.Filter = sql;
            }
            grdvDSMatHang.DataSource = bindingSource1;
            AnCotTrenLuoi();
            DinhDangCot();
        }