Ejemplo n.º 1
0
        public DataTable Search_HangTonKho(string keyWord)
        {
            SqlConnection cn = new SqlConnection(cnString);

            cn = CDatabase.Get_Database_Connection();

            DataTable tb = new DataTable();

            try
            {
                string sqlText = "SELECT h.MAHH as 'Mã hàng hóa', h.TENHH as 'Tên hàng hóa', n.TENNHOM as 'Tên nhóm hàng', h.SLTON as 'Số lượng còn trong kho' from HANG_HOA h, NHOM_HANG n WHERE h.MANHOM=n.MANHOM AND (h.MAHH LIKE '%" + keyWord + "%'OR h.TENHH LIKE '%" + keyWord + "%' OR n.TENNHOM LIKE '%" + keyWord + "%')";
                tb = CDatabase.Get_Data_Table(sqlText);

                CDatabase.Execute_SQL(sqlText);
                //MyDataGrid_SP.DataContext = tb.DefaultView;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                CDatabase.Close_Database_Connection();
            }
            return(tb);
        }
Ejemplo n.º 2
0
        public DataTable Select()
        {
            SqlConnection cn = new SqlConnection(cnString);

            cn = CDatabase.Get_Database_Connection();

            DataTable tb = new DataTable();

            try
            {
                string sqlText = "SELECT * from HANG_HOA";
                tb = CDatabase.Get_Data_Table(sqlText);

                CDatabase.Execute_SQL(sqlText);
                //MyDataGrid_SP.DataContext = tb.DefaultView;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                CDatabase.Close_Database_Connection();
            }
            return(tb);
        }
Ejemplo n.º 3
0
        public void DoanhThu_HomNay()
        {
            SqlConnection cn = new SqlConnection(cnString);

            cn = CDatabase.Get_Database_Connection();

            DataTable tb = new DataTable();

            try
            {
                string sqlText = "SELECT * FROM HOA_DON WHERE month(getdate())=month(NGAYNHAP)";
                tb = CDatabase.Get_Data_Table(sqlText);

                CDatabase.Execute_SQL(sqlText);
                //MyDataGrid_SP.DataContext = tb.DefaultView;

                object SumRevenue = null;
                SumRevenue = tb.Compute("Sum(TONGTIEN)", "");
                MessageBox.Show("Doanh thu là : " + SumRevenue.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                CDatabase.Close_Database_Connection();
            }
        }