Ejemplo n.º 1
0
        private void gridViewGiaXuatSP_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                if (e.Column == colDeleteGia)
                {
                    GiaXuatSP objGiaXuatSP = new GiaXuatSP();
                    objGiaXuatSP.IDGiaXuatSP = Convert.ToInt32(gridViewGiaXuatSP.GetRowCellValue(e.RowHandle, "IDGiaXuatSP"));

                    if (Convert.ToBoolean(gridViewGiaXuatSP.GetRowCellValue(e.RowHandle, colDeleteGia)) == true)
                    {
                        //warnning
                        if (MessageBox.Show(this, "Bạn có muốn xóa Giá sản phẩm này không?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            if (new DataAccess().deleteGiaXuatSP(objGiaXuatSP) == true)
                            {
                                ((frmMain)(this.MdiParent)).setStatus("Xóa Giá sản phẩm thành công");
                                gridViewGiaXuatSP.DeleteRow(e.RowHandle);
                            }
                            else
                            {
                                MessageBox.Show(this, "Xóa Giá sản phẩm 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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private bool GiaXuatSPValidation(GiaXuatSP objGiaXuatSP)
 {
     if (objGiaXuatSP.Gia <= 0)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        private void gridViewGiaXuatSP_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
                GiaXuatSP objGiaXuatSP = new GiaXuatSP();

                objGiaXuatSP.IDSanPham = curIDSanPham;
                if (Convert.ToString(aRow["NgayXuatSP"]) == "")
                {
                    gridControlGiaXuatSP.DataSource = new DataAccess().getGiaXuatSPByIDSanPham(curIDSanPham).Tables[0];
                    MessageBox.Show(this, "Chưa nhập Ngày Giá sản phẩm!", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    objGiaXuatSP.NgayXuatSP = Convert.ToDateTime(aRow["NgayXuatSP"]);
                }
                if (Convert.ToString(aRow["Gia"]) == "")
                {
                    gridControlGiaXuatSP.DataSource = new DataAccess().getGiaXuatSPByIDSanPham(curIDSanPham).Tables[0];
                    MessageBox.Show(this, "Chưa nhập Giá sản phẩm!", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    objGiaXuatSP.Gia = Convert.ToDecimal(aRow["Gia"]);
                    if (objGiaXuatSP.Gia <= 0)
                    {
                        gridControlGiaXuatSP.DataSource = new DataAccess().getGiaXuatSPByIDSanPham(curIDSanPham).Tables[0];
                        MessageBox.Show(this, "Giá sản phẩm chưa hợp lệ!", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                objGiaXuatSP.Ghichu = Convert.ToString(aRow["Ghichu"]);


                if (new DataAccess().insertGiaXuatSP(objGiaXuatSP) >= 0)
                {
                    gridControlGiaXuatSP.DataSource = new DataAccess().getGiaXuatSPByIDSanPham(curIDSanPham).Tables[0];
                    ((frmMain)(this.MdiParent)).setStatus("Thêm mới Giá sản phẩm thành công");
                }
                else
                {
                    gridControlGiaXuatSP.DataSource = new DataAccess().getGiaXuatSPByIDSanPham(curIDSanPham).Tables[0];
                    MessageBox.Show(this, "Thêm mới Giá sản phẩm không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ((frmMain)(this.MdiParent)).setStatus("");
                }
            }
        }
Ejemplo n.º 4
0
        private void gridViewGiaXuatSP_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                if (e.Column == colDeleteGia)
                {
                    //do nothing
                }
                else
                {
                    //update here
                    GiaXuatSP objGiaXuatSP = new GiaXuatSP();
                    objGiaXuatSP.IDGiaXuatSP = Convert.ToInt32(gridViewGiaXuatSP.GetRowCellValue(e.RowHandle, "IDGiaXuatSP"));
                    objGiaXuatSP.IDSanPham   = Convert.ToInt32(gridViewGiaXuatSP.GetRowCellValue(e.RowHandle, "IDSanPham"));
                    objGiaXuatSP.Gia         = Convert.ToDecimal(gridViewGiaXuatSP.GetRowCellValue(e.RowHandle, "Gia"));
                    objGiaXuatSP.NgayXuatSP  = Convert.ToDateTime(gridViewGiaXuatSP.GetRowCellValue(e.RowHandle, "NgayXuatSP"));
                    objGiaXuatSP.Ghichu      = Convert.ToString(gridViewGiaXuatSP.GetRowCellValue(e.RowHandle, "Ghichu"));

                    if (objGiaXuatSP.Gia >= 0)
                    {
                        if (new DataAccess().updateGiaXuatSP(objGiaXuatSP) == true)
                        {
                            ((frmMain)(this.MdiParent)).setStatus("Cập nhật dữ liệu Giá sản phẩm thành công");
                        }
                        else
                        {
                            MessageBox.Show(this, "Cập nhật dữ liệu Giá sản phẩm không thành công", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        gridControlGiaXuatSP.DataSource = new DataAccess().getGiaXuatSPByIDSanPham(curIDSanPham).Tables[0];
                        getBangNguyenLieu(curIDSanPham);
                        MessageBox.Show(this, "Giá sản phẩm không hợp lệ.", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public bool updateGiaXuatSP(GiaXuatSP objGiaXuatSP)
 {
     return(new GiaXuatSPService().updateGiaXuatSP(objGiaXuatSP));
 }
Ejemplo n.º 6
0
 public int insertGiaXuatSP(GiaXuatSP objGiaXuatSP)
 {
     return(new GiaXuatSPService().insertGiaXuatSP(objGiaXuatSP));
 }
Ejemplo n.º 7
0
 public bool deleteGiaXuatSP(GiaXuatSP objGiaXuatSP)
 {
     return(new GiaXuatSPService().deleteGiaXuatSP(objGiaXuatSP));
 }