Esempio n. 1
0
        private void gridViewCongThucPhaChe_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                if (e.Column == colDeleteCTPhaChe)
                {
                    SPPhaChe objSPPhaChe = new SPPhaChe();
                    objSPPhaChe.IDSPPhaChe = Convert.ToInt32(gridViewCongThucPhaChe.GetRowCellValue(e.RowHandle, "IDSPPhaChe"));


                    if (Convert.ToBoolean(gridViewCongThucPhaChe.GetRowCellValue(e.RowHandle, colDeleteCTPhaChe)) == true)
                    {
                        //warnning
                        if (MessageBox.Show(this, "Bạn có muốn xóa Thành phần nguyên liệu này không?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            if (new DataAccess().deleteSPPhaChe(objSPPhaChe) == true)
                            {
                                ((frmMain)(this.MdiParent)).setStatus("Xóa thành phần nguyên liệu thành công");
                                gridViewCongThucPhaChe.DeleteRow(e.RowHandle);
                            }
                            else
                            {
                                MessageBox.Show(this, "Xóa thành phần nguyên liệu không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                ((frmMain)(this.MdiParent)).setStatus("");
                            }
                        }
                        else
                        {
                            //set the image to uncheck
                            gridViewSanPham.SetRowCellValue(e.RowHandle, colDeleteSanPham, true);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void gridViewCongThucPhaChe_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            DataRowView aRowView = (DataRowView)(e.Row);
            DataRow     aRow     = aRowView.Row;

            if (aRow.RowState == DataRowState.Added)
            {
                //insert command here
                SPPhaChe objSPPhaChe = new SPPhaChe();

                objSPPhaChe.IDSanPham = curIDSanPham;
                if (Convert.ToString(aRow["TenSanPham"]) == "")
                {
                    getBangNguyenLieu(curIDSanPham);
                    MessageBox.Show(this, "Chưa nhập tên thành phần nguyên liệu cho sản phẩm!", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    objSPPhaChe.IDSPCha = Convert.ToInt32(new DataAccess().getIDSanPhamByTenSP(aRow["TenSanPham"].ToString()).Tables[0].Rows[0][0]);
                }
                if (Convert.ToString(aRow["ThanhPhan"]) == "")
                {
                    getBangNguyenLieu(curIDSanPham);
                    MessageBox.Show(this, "Chưa nhập thành phần nguyên liệu cho sản phẩm!", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    objSPPhaChe.ThanhPhan = Convert.ToInt32(aRow["ThanhPhan"]);
                    if (objSPPhaChe.ThanhPhan < 0)
                    {
                        getBangNguyenLieu(curIDSanPham);
                        MessageBox.Show(this, "Thành phần pha chế chưa hợp lệ!", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                objSPPhaChe.GhiChu = Convert.ToString(aRow["GhiChu"]);


                if (new DataAccess().insertSPPhaChe(objSPPhaChe) >= 0)
                {
                    getBangNguyenLieu(curIDSanPham);
                    ((frmMain)(this.MdiParent)).setStatus("Thêm mới Thành phần nguyên liệu thành công");
                }
                else
                {
                    getBangNguyenLieu(curIDSanPham);
                    MessageBox.Show(this, "Thêm mới thành phần nguyên liệu không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ((frmMain)(this.MdiParent)).setStatus("");
                }
            }
        }
Esempio n. 3
0
        private void gridViewCongThucPhaChe_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                if (e.Column == colDeleteCTPhaChe)
                {
                    //do nothing
                }
                else
                {
                    //update here
                    SPPhaChe objSPPhaChe = new SPPhaChe();

                    objSPPhaChe.IDSPPhaChe = Convert.ToInt32(gridViewCongThucPhaChe.GetRowCellValue(e.RowHandle, "IDSPPhaChe"));
                    objSPPhaChe.IDSanPham  = Convert.ToInt32(gridViewCongThucPhaChe.GetRowCellValue(e.RowHandle, "IDSanPham"));
                    objSPPhaChe.IDSPCha    = Convert.ToInt32(new DataAccess().getIDSanPhamByTenSP(gridViewCongThucPhaChe.GetRowCellValue(e.RowHandle, "TenSanPham").ToString()).Tables[0].Rows[0][0]);
                    objSPPhaChe.GhiChu     = Convert.ToString(gridViewCongThucPhaChe.GetRowCellValue(e.RowHandle, "GhiChu"));
                    objSPPhaChe.ThanhPhan  = Convert.ToInt32(gridViewCongThucPhaChe.GetRowCellValue(e.RowHandle, "ThanhPhan"));


                    if (objSPPhaChe.ThanhPhan >= 0)
                    {
                        if (new DataAccess().updateSPPhaChe(objSPPhaChe) == true)
                        {
                            ((frmMain)(this.MdiParent)).setStatus("Cập nhật dữ liệu bảng nguyên liệu thành công");
                        }
                        else
                        {
                            MessageBox.Show(this, "Cập nhật dữ liệu bảng nguyên liệu không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        getBangNguyenLieu(curIDSanPham);
                        MessageBox.Show(this, "Thành phần nguyên liệu không hợp lệ.", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Esempio n. 4
0
 public bool deleteSPPhaChe(SPPhaChe objSPPhaChe)
 {
     return(new SPPhaCheService().deleteSPPhaChe(objSPPhaChe));
 }
Esempio n. 5
0
 public bool updateSPPhaChe(SPPhaChe objSPPhaChe)
 {
     return(new SPPhaCheService().updateSPPhaChe(objSPPhaChe));
 }
Esempio n. 6
0
 public int insertSPPhaChe(SPPhaChe objSPPhaChe)
 {
     return(new SPPhaCheService().insertSPPhaChe(objSPPhaChe));
 }