Ejemplo n.º 1
0
        public static DataTable docDuLieu(string query)
        {
            DataTable     table = new DataTable();
            SqlConnection con   = KetNoiDatabase.ketNoiDatabase();

            SqlDataAdapter adap;

            try
            {
                //    System.Windows.Forms.MessageBox.Show(query);
                con.Open();
                adap = new SqlDataAdapter(query, con);

                adap.Fill(table);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                table = null;
            }

            con.Close();

            return(table);
        }
Ejemplo n.º 2
0
        public static List <int> LayDanhSachPhanQuyen(int maNhanVien)
        {
            List <int> ds    = new List <int>();
            string     query = "select MaCN from PhanQuyenNhanVien where MaNV = " + maNhanVien;
            DataTable  table = KetNoiDatabase.docDuLieu(query);

            foreach (DataRow row in table.Rows)
            {
                ds.Add((int)row[0]);
            }


            return(ds);
        }
Ejemplo n.º 3
0
        public static bool thaoTacDuLieu(string query)
        {
            SqlConnection con = KetNoiDatabase.ketNoiDatabase();

            SqlCommand cmd   = null;
            bool       hopLe = true;

            try
            { cmd = new SqlCommand(query, con);
              cmd.ExecuteNonQuery(); }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                hopLe = false;
            }

            con.Close();

            return(hopLe);
        }