Ejemplo n.º 1
0
        private void Button_SearchTenSP_Click(object sender, RoutedEventArgs e)
        {
            string str = TextBox_SearchTenSP.Text;

            try
            {
                //Cách 2
                string        cnString = Properties.Settings.Default.connString;
                SqlConnection cn       = new SqlConnection(cnString);
                cn = CDatabase.Get_Database_Connection();

                string sqlText = "SELECT TENHH as 'Tên hàng hóa', SLTON as 'Số lượng tồn' FROM HANG_HOA WHERE TENHH like '%" + str + "%' ";

                DataTable tb = new DataTable();
                tb = CDatabase.Get_Data_Table(sqlText);

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

                CDatabase.Close_Database_Connection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void db_Read_Record_SP()
        {
            try
            {
                //Cách 2
                string        cnString = Properties.Settings.Default.connString;
                SqlConnection cn       = new SqlConnection(cnString);
                cn = CDatabase.Get_Database_Connection();

                string sqlText = "SELECT pp.TENHH as 'Tên hàng hóa', sum(p.SLBAN) 'Số lượng bán được' FROM CTHD p, HANG_HOA pp WHERE p.MAHH=pp.MAHH GROUP BY p.MAHH, pp.TENHH  ORDER BY sum(p.SLBAN) DESC ";

                DataTable tb = new DataTable();
                tb = CDatabase.Get_Data_Table(sqlText);

                CDatabase.Execute_SQL(sqlText);
                MyDataGrid_LoaiSP.DataContext = tb.DefaultView;

                CDatabase.Close_Database_Connection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }