Пример #1
0
        private void SaveSanPham()
        {
            int Id = 0;

            int.TryParse(gridView.GetRowCellValue(gridView.FocusedRowHandle, "MaSanPham").ToString(), out Id);
            if (string.IsNullOrEmpty(gridView.GetRowCellValue(gridView.FocusedRowHandle, "TenSanPham").ToString()))
            {
                MessageBox.Show("Vui lòng nhập tên sản phẫm.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrEmpty(gridView.GetRowCellValue(gridView.FocusedRowHandle, "DonGia").ToString()))
            {
                MessageBox.Show("Vui lòng nhập đơn giá.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrEmpty(gridView.GetRowCellValue(gridView.FocusedRowHandle, "DonGiaCM").ToString()))
            {
                MessageBox.Show("Vui lòng nhập đơn giá CM.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrEmpty(gridView.GetRowCellValue(gridView.FocusedRowHandle, "ProductionTime").ToString()))
            {
                MessageBox.Show("Vui lòng thời gian chế tạo sản phẫm.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrEmpty(gridView.GetRowCellValue(gridView.FocusedRowHandle, "ProductionTime").ToString()) &&
                     Convert.ToDouble(gridView.GetRowCellValue(gridView.FocusedRowHandle, "ProductionTime").ToString()) <= 0)
            {
                MessageBox.Show("Thời gian chế tạo Mặt Hàng phải lớn hơn 0, hoặc bạn nhập sai định dạng dữ liệu.\n", "Lỗi nhập liệu");
            }
            else
            {
                var obj = new SanPham();
                obj.MaSanPham      = Id;
                obj.Floor          = floorDefault;
                obj.TenSanPham     = gridView.GetRowCellValue(gridView.FocusedRowHandle, "TenSanPham").ToString();
                obj.DonGia         = Convert.ToDouble(gridView.GetRowCellValue(gridView.FocusedRowHandle, "DonGia").ToString());
                obj.DonGiaCM       = Convert.ToDouble(gridView.GetRowCellValue(gridView.FocusedRowHandle, "DonGiaCM").ToString());
                obj.ProductionTime = Convert.ToDouble(gridView.GetRowCellValue(gridView.FocusedRowHandle, "ProductionTime").ToString());
                obj.DinhNghia      = gridView.GetRowCellValue(gridView.FocusedRowHandle, "DinhNghia") != null?gridView.GetRowCellValue(gridView.FocusedRowHandle, "DinhNghia").ToString() : "";

                if (gridView.GetRowCellValue(gridView.FocusedRowHandle, "MaKhachHang") != null)
                {
                    obj.MaKhachHang = gridView.GetRowCellValue(gridView.FocusedRowHandle, "MaKhachHang").ToString();
                }

                if (gridView.GetRowCellValue(gridView.FocusedRowHandle, "DonGiaCat") != null)
                {
                    obj.DonGiaCat = Convert.ToDouble(gridView.GetRowCellValue(gridView.FocusedRowHandle, "DonGiaCat").ToString());
                }

                var rs = BLLCommodity.InsertOrUpdate(obj);
                if (rs.IsSuccess)
                {
                    LoadProduct_Grid();
                }
                else
                {
                    MessageBox.Show(rs.Messages[0].msg, rs.Messages[0].Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void LoadDSSamPham()
        {
            lueSanPham.Text = "(--Chọn Mặt Hàng--)";
            var listProduct = BLLCommodity.GetAll(int.Parse(AccountSuccess.IdFloor), AccountSuccess.IsAll);

            if (listProduct != null && listProduct.Count > 0)
            {
                lueSanPham.Properties.DataSource    = listProduct;
                lueSanPham.Properties.DisplayMember = "TenSanPham";
                lueSanPham.Properties.ValueMember   = "MaSanPham";
            }
        }
Пример #3
0
        private void repbtnDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            int Id = int.Parse(gridView.GetRowCellValue(gridView.FocusedRowHandle, "MaSanPham").ToString());

            if (Id != 0)
            {
                if (MessageBox.Show("Bạn có muốn xoá không?", "Xoá đối tượng", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    var result = BLLCommodity.Delete(Id);
                    if (result.IsSuccess)
                    {
                        LoadProduct_Grid();
                    }
                    else
                    {
                        MessageBox.Show(result.Messages[0].msg, result.Messages[0].Title);
                    }
                }
            }
        }
Пример #4
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            var floor = ((PMS.Data.Floor)cboFloorProduct.SelectedItem);

            if (txtMaMatHang.Text != "")
            {
                var rs = BLLCommodity.Delete(int.Parse(txtMaMatHang.Text));
                if (rs.IsSuccess)
                {
                    MessageBox.Show(rs.Messages[0].msg, rs.Messages[0].Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadMatHangRaDataGridView(floor.IdFloor.ToString());
                }
                else
                {
                    MessageBox.Show(rs.Messages[0].msg, rs.Messages[0].Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Vui lòng chọn tên mặt hàng bạn muốn xoá", "Lỗi xử lý", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
        private void LoadProduct_Grid()
        {
            try
            {
                gridProduct.DataSource = null;
                var item = (Floor)cbFloor.SelectedItem;

                if (item != null && item.IdFloor != 0)
                {
                    var pro = new List <SanPham>();
                    pro.Add(new SanPham()
                    {
                        MaSanPham = 0, TenSanPham = ""
                    });
                    pro.AddRange(BLLCommodity.GetAll(item.IdFloor, AccountSuccess.IsAll));

                    gridProduct.DataSource = pro;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi lấy danh sách mã hàng.\n" + ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public ResponseBase Delete(int Id)
 {
     return(BLLCommodity.Delete(Id));
 }
 public ResponseBase Save(SanPham model)
 {
     return(BLLCommodity.InsertOrUpdate(model));
 }
        public List <ProductModel> Gets(int FloorId, int IsAll)
        {
            return(BLLCommodity.Gets(FloorId, IsAll));

            BLLSize.Instance.Gets
        }