Beispiel #1
0
        //tự động tăng ID nhân viên khi insert
        public string tangIDNV()
        {
            DAL.SQLConnect conn = new DAL.SQLConnect();
            conn.OpenConnect();
            string         sql = "select * from tbEmployees";
            SqlCommand     cmd = new SqlCommand(sql, conn.Connection);//sqlconnection
            SqlDataAdapter da  = new SqlDataAdapter(cmd);

            DataTable dt = new DataTable();

            da.Fill(dt);
            string id = "";

            if (dt.Rows.Count <= 0)
            {
                id = "NV01";
            }
            else
            {
                int k = 0;
                id = "NV";
                k  = Convert.ToInt32(dt.Rows[dt.Rows.Count - 1][0].ToString().Substring(2, 2));
                k += 1;
                if (k < 10)
                {
                    id += "0";
                }
                id += k.ToString();
            }
            return(id);
        }
Beispiel #2
0
        private void btnDeleteMenu_Click(object sender, EventArgs e)
        {
            DAL.SQLConnect conn = new DAL.SQLConnect();
            conn.OpenConnect();
            string     sqlDelete = "delete from tbDish where ID_dish=@ID_dish";
            SqlCommand cmd       = new SqlCommand(sqlDelete, conn.Connection);//sqlconnection

            cmd.Parameters.AddWithValue("ID_dish", txtIDDish.Text);
            cmd.Parameters.AddWithValue("Name_dish", txtNameDish.Text);
            cmd.Parameters.AddWithValue("Unit_price", txtUnitPrice.Text);
            cmd.ExecuteNonQuery();
            showListMenu();
        }
Beispiel #3
0
        private void btnAddMenu_Click(object sender, EventArgs e)
        {
            DAL.SQLConnect conn = new DAL.SQLConnect();
            conn.OpenConnect();
            string     sqlAdd = "insert into tbDish values(@ID_dish,@Name_dish,@Unit_price)";
            SqlCommand cmd    = new SqlCommand(sqlAdd, conn.Connection);//sqlconnection

            cmd.Parameters.AddWithValue("ID_dish", txtIDDish.Text);
            cmd.Parameters.AddWithValue("Name_dish", txtNameDish.Text);
            cmd.Parameters.AddWithValue("Unit_price", txtUnitPrice.Text);
            cmd.ExecuteNonQuery();
            showListMenu();
        }
Beispiel #4
0
        public void showListNhanVien()
        {
            //DAL.SQLConnect conn = new DAL.SQLConnect();
            //dataGridViewNV.DataSource = conn.getDataTable("tbEmployees");

            clearLsvNhanVien();
            DAL.SQLConnect conn = new DAL.SQLConnect();
            SqlDataReader  dr   = conn.getDataTableNV("tbEmployees");

            while (dr.Read())
            {
                addlist(dr);
            }
        }
Beispiel #5
0
 public void LoadComboBox2()
 {
     try
     {
         DAL.SQLConnect provider = new DAL.SQLConnect();
         string         query    = ("select Name_employees,ID_employees from tbEmployees");
         cbbNameEmployees.DataSource    = provider.ExecuteQuery(query);
         cbbNameEmployees.DisplayMember = "Name_employees";
         cbbNameEmployees.ValueMember   = "Name_employees";
     }
     catch (Exception ex)
     {
         new Exception("Error " + ex.ToString());
     }
 }
Beispiel #6
0
        //phạm ngọc đạt
        #region tabPage BanHang

        public void LoadComboBox()
        {
            try
            {
                DAL.SQLConnect provider = new DAL.SQLConnect();
                string         query    = "select Name_dish,Unit_price from tbDish";
                cbbNameEat.DataSource    = provider.ExecuteQuery(query);
                cbbNameEat.DisplayMember = "Name_dish";
                cbbNameEat.ValueMember   = "Name_dish";
            }
            catch (Exception ex)
            {
                throw new Exception("Error " + ex.ToString());
            }
        }
Beispiel #7
0
        private void btnSearchDish_Click(object sender, EventArgs e)
        {
            DAL.SQLConnect conn = new DAL.SQLConnect();
            conn.OpenConnect();
            string     sqlSearchID = "select* from tbDish where ID_dish=@ID_dish";
            SqlCommand cmd         = new SqlCommand(sqlSearchID, conn.Connection);//sqlconnection

            cmd.Parameters.AddWithValue("ID_dish", txtSearchDish.Text);
            cmd.ExecuteNonQuery();
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable     dt = new DataTable();

            dt.Load(dr);
            dGvMenu.DataSource = dt;
        }
Beispiel #8
0
 //Trần Phương Thảo
 #region tabPage Menu
 public void showListMenu()
 {
     DAL.SQLConnect conn = new DAL.SQLConnect();
     dGvMenu.DataSource = conn.getDataTable("tbDish");
 }