//them nguyen lieu
        private void button1_Click(object sender, EventArgs e)
        {
            if (!testtext1())
            {
                return;
            }
            DSNguyenLieuDTO dsnl = new DSNguyenLieuDTO();

            dsnl.manl    = comboBox1.Text;
            dsnl.mama    = label6.Text;
            dsnl.soluong = int.Parse(textBox4.Text);

            //2. Kiểm tra data hợp lệ or not
            if (dsnlBUS.TimNLtrongMA(dsnl.manl, dsnl.mama))
            {
                System.Windows.MessageBox.Show("Thêm nguyên liệu thất bại. nguyên liệu đã tồn tại.");
                return;
            }
            //kiem tra luong ton kho

            //3. Thêm vào DB
            bool kq = dsnlBUS.Them(dsnl);

            if (kq == false)
            {
                System.Windows.MessageBox.Show("Thêm nguyên liệu thất bại. Vui lòng kiểm tra lại dữ liệu");
            }
            else
            {
                System.Windows.MessageBox.Show("Thêm nguyên liệu thành công");
            }
            loadData_Vao_GridView();
            Tinhtien();
        }
        //xoa nguyen lieu
        private void xóaMónĂnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int currentRowIndex = dataGridView1.CurrentCellAddress.Y;// 'current row selected

            //'Verify that indexing OK
            if (-1 < currentRowIndex && currentRowIndex < dataGridView1.RowCount)
            {
                DSNguyenLieuDTO dsnl = (DSNguyenLieuDTO)dataGridView1.Rows[currentRowIndex].DataBoundItem;
                if (dsnl != null)
                {
                    bool kq = dsnlBUS.Xoa(dsnl);
                    if (kq == false)
                    {
                        MessageBox.Show("Xóa nguyên liệu thất bại. Vui lòng kiểm tra lại dũ liệu");
                    }
                    else
                    {
                        MessageBox.Show("Xóa nguyên liệu thành công");
                        loadData_Vao_GridView();
                        Tinhtien();
                    }
                }
            }
        }
Exemple #3
0
        public bool Xoa(DSNguyenLieuDTO ma)
        {
            bool re = dsnlDAL.Xoa(ma);

            return(re);
        }
Exemple #4
0
        public bool Them(DSNguyenLieuDTO ma)
        {
            bool re = dsnlDAL.Them(ma);

            return(re);
        }