Exemplo n.º 1
0
        private void Report_tblHoadonbanhang_Load(object sender, EventArgs e)
        {
            //List<tblHoadonbanhang> listHoadon = new List<tblHoadonbanhang>();
            //listHoadon = new XuLy_tblHoadonbanhang().tblHoadonbanhang_Select(0);

            DataTable t = new DataTable();

            t = new XuLy_tblHoadonbanhang().TimKiem(sql);

            //DataSet dataSet = new DataSet();
            //DataTable dataTable = new XuLy_tblHoadonbanhang().TimKiem(sql);
            //dataSet.Tables.Add(dataTable);

            Report_Hoadon rp = new Report_Hoadon();

            //CrystalReport_tblHoadonbanhang rp = new CrystalReport_tblHoadonbanhang();
            rp.SetDataSource(t);
            crystalReportViewer_tblHoadonbanhang.ReportSource = rp;
            //crystalReportViewer_tblHoadonbanhang.Show();
        }
Exemplo n.º 2
0
        public BanHang(int HoadonbanhangID)
        {
            InitializeComponent();
            labelHoadonbanhangID.Visible = txtHoadonbanhangID.Visible = true;
            dateThoigianban.Enabled      = true;
            Mahoadon = HoadonbanhangID;

            txtHoadonbanhangID.Text = Mahoadon.ToString();
            tblHoadonbanhang hoadon = new XuLy_tblHoadonbanhang().tblHoadonbanhang_Select(Mahoadon)[0];

            txtNhanvienID.Text    = hoadon.FK_iNhanvienID.ToString();
            txtTenKhachhang.Text  = hoadon.sTenKhachhang;
            txtDiachi.Text        = hoadon.sDiachi;
            txtSdt.Text           = hoadon.sSdt;
            dateThoigianban.Value = hoadon.dThoigianban;
            txtTongtien.Text      = hoadon.iTongtien.ToString();

            sFilter += string.Format(" and tblHangban.FK_iHoadonbanhangID = '{0}' ", Mahoadon.ToString());
            table    = new XuLy_tblHangban().TimKiem(sFilter);
            dataGridViewtblHangban.DataSource = table;
            dataGridViewtblHangban.ClearSelection();
        }
Exemplo n.º 3
0
        private void TimKiem()
        {
            sFilter = " 1>0 ";
            if (!string.IsNullOrEmpty(txtHoadonbanhangID.Text.Trim()))
            {
                if (sFilter == " 1>0 ")
                {
                    sFilter = string.Format(" PK_iHoadonbanhangID = '{0}' ", txtHoadonbanhangID.Text.Trim().ToString());
                }
                else
                {
                    sFilter += string.Format("or PK_iHoadonbanhangID = '{0}' ", txtHoadonbanhangID.Text.Trim().ToString());
                }
            }


            if (!string.IsNullOrEmpty(txtNhanvienID.Text.Trim()))
            {
                if (sFilter == " 1>0 ")
                {
                    sFilter = string.Format(" sTenKhachhang LIKE '%{0}%' ", txtTenKhachhang.Text.Trim());
                }
                else
                {
                    sFilter += string.Format(" or sTenKhachhang LIKE '%{0}%' ", txtTenKhachhang.Text.Trim());
                }
            }

            if (!string.IsNullOrEmpty(txtTenKhachhang.Text.Trim()))
            {
                if (sFilter == " 1>0 ")
                {
                    sFilter = string.Format(" sTenKhachhang LIKE '%{0}%' ", txtTenKhachhang.Text.Trim());
                }
                else
                {
                    sFilter += string.Format(" or sTenKhachhang LIKE '%{0}%' ", txtTenKhachhang.Text.Trim());
                }
            }

            if (!string.IsNullOrEmpty(txtTenNhanvien.Text.Trim()))
            {
                sFilter += string.Format(" or tblNhanvien.sTenNhanvien LIKE '%{0}%' ", txtTenNhanvien.Text.Trim());
            }

            if (!string.IsNullOrEmpty(txtDiachi.Text.Trim()))
            {
                sFilter += string.Format(" or sDiachi LIKE '%{0}%' ", txtDiachi.Text.Trim());
            }

            if (!string.IsNullOrEmpty(txtSdt.Text.Trim()))
            {
                if (sFilter == " 1>0 ")
                {
                    sFilter = string.Format(" sSdt LIKE '%{0}%' ", txtSdt.Text.Trim());
                }
                else
                {
                    sFilter += string.Format(" or sSdt LIKE '%{0}%' ", txtSdt.Text.Trim());
                }
            }

            if (checkBoxNgay.Checked == true)
            {
                sFilter += string.Format(" or dThoigianban = '{0}' ", dateThoigianban.Text.ToString());
            }
            if (checkBoxThang.Checked == true)
            {
                sFilter += string.Format(" or MONTH(dThoigianban) = MONTH('{0}') and YEAR(dThoigianban) = YEAR('{0}') ",
                                         dateThoigianban.Text.ToString(), dateThoigianban.Text.ToString());
            }
            if (checkBoxNam.Checked == true)
            {
                sFilter += string.Format(" or YEAR(dThoigianban) = YEAR('{0}') ", dateThoigianban.Text.ToString());
            }

            DataTable table = new XuLy_tblHoadonbanhang().TimKiem(sFilter);

            dataGridViewHoadonbanhang.DataSource = table;
            dataGridViewHoadonbanhang.ClearSelection();

            if (dataGridViewHoadonbanhang.Rows.Count == 1)
            {
                dataGridViewHoadonbanhang.SelectAll();
                buttonSua.Tag     = buttonXoa.Tag = dataGridViewHoadonbanhang.Rows[0].Cells[0];
                buttonSua.Enabled = true;
                buttonXoa.Enabled = true;
            }
            else
            {
                dataGridViewHoadonbanhang.ClearSelection();
                buttonSua.Enabled = false;
                buttonXoa.Enabled = false;
            }
        }