Example #1
0
        public UcInfo(DTO.NguyenLieu data)
        {
            InitializeComponent();

            this.data = data;
            isUpdate = true;
            lbSelect.Text = Constant.DEFAULT_TITLE_EDIT;

            if (Init())
            {
                tbMaNL.Text = data.MaNguyenLieu;
                tbTen.Text = data.Ten;
                cbDVTNL.Text = data.DonViTinh;

                if (data.IsActive)
                {
                    rbSuDung.Checked = true;
                }
                else
                {
                    rbTamNgung.Checked = true;
                }

                tbMoTa.Text = data.MoTa;
            }
            else
            {
                this.Visible = false;
            }
        }
Example #2
0
        public static bool Delete(NguyenLieu data, User user)
        {
            try
            {
                if (data != null)
                {
                    NguyenLieu objDb = GetById(data.Id);

                    if (objDb != null)
                    {
                        objDb.DeleteFlag = true;
                        dbContext.SubmitChanges();

                        return true;
                    }
                }
            }
            catch
            {

            }

            CreateSQlConnection();

            return false;
        }
Example #3
0
        private void btnChon_Click(object sender, EventArgs e)
        {
            if (phieuNhapHang.NgayGiao != "" && phieuNhapHang.NgayGiao != null)
            {
                MessageBox.Show("Đơn đặt hàng đã giao bạn không được phép sửa");
                return;
            }
            if (dGVNguyenLieu.CurrentRow != null)
            {
                int            index      = dGVNguyenLieu.CurrentRow.Index;
                string         soHD       = dGVNguyenLieu[5, index].Value.ToString();
                DTO.NguyenLieu nguyenLieu = bindingListNguyenLieu[index];

                if (hashMaHangHoa.Contains(nguyenLieu.Ma))
                {
                    for (int i = 0; i < bindingSource.Count; i++)
                    {
                        if (((PhieuNhapHangDataSource)bindingSource[i]).Ma == nguyenLieu.Ma)
                        {
                            index = i;
                            break;
                        }
                    }

                    dGVHoaDon[4, index].Value = int.Parse(dGVHoaDon[4, index].Value.ToString()) + 1;
                    dGVHoaDon[5, index].Value = int.Parse(dGVHoaDon[3, index].Value.ToString()) *
                                                int.Parse(dGVHoaDon[4, index].Value.ToString());
                    TongCong = TongCong + nguyenLieu.Dongia;
                    return;
                }

                string maHangHoa = nguyenLieu.Ma;



                hashMaHangHoa.Add(maHangHoa);
                bindingSource.Add(new PhieuNhapHangDataSource()
                {
                    Ma        = nguyenLieu.Ma,
                    Ten       = nguyenLieu.Ten,
                    DonViTinh = nguyenLieu.DonViTinh,
                    Gia       = nguyenLieu.Dongia.ToString(),
                    Loai      = nguyenLieu.Loai,
                    Soluong   = "1",
                    Thanhtien = nguyenLieu.Dongia.ToString(),
                });
                TongCong = TongCong + nguyenLieu.Dongia;
            }
        }
Example #4
0
        public UcInfo()
        {
            InitializeComponent();

            data = new DTO.NguyenLieu();
            isUpdate = false;

            if (Init())
            {
                RefreshData();
            }
            else
            {
                this.Visible = false;
            }
        }
Example #5
0
 partial void DeleteNguyenLieu(NguyenLieu instance);
Example #6
0
 partial void UpdateNguyenLieu(NguyenLieu instance);
Example #7
0
 partial void InsertNguyenLieu(NguyenLieu instance);
Example #8
0
        private void InsertData()
        {
            data = new DTO.NguyenLieu();

            data.MaNguyenLieu = tbMaNL.Text;
            data.Ten = tbTen.Text;
            data.DonViTinh = cbDVTNL.Text;
            data.HanMuc = ConvertUtil.ConvertToDouble(tbHanMuc.Text);
            data.IsActive = rbSuDung.Checked;
            data.MoTa = tbMoTa.Text;

            if (NguyenLieuBus.Insert(data, FormMain.user))
            {
                ConfirmContinue();
            }
            else
            {
                if (MessageBox.Show(string.Format(Constant.MESSAGE_INSERT_ERROR_DUPLICATED, tbTen.Text) +
                    Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    this.Dispose();
                }
            }
        }
Example #9
0
 public static bool Update(NguyenLieu data, User user)
 {
     return NguyenLieuDao.Update(data, user);
 }
Example #10
0
 public static bool Insert(NguyenLieu data, User user)
 {
     return NguyenLieuDao.Insert(data, user);
 }
Example #11
0
 public static bool Delete(NguyenLieu data, User user)
 {
     return NguyenLieuDao.Delete(data, user);
 }
Example #12
0
        public static bool Update(NguyenLieu data, User user)
        {
            try
            {
                if (data != null)
                {
                    dbContext.SubmitChanges();

                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
Example #13
0
        public static bool Insert(NguyenLieu data, User user)
        {
            try
            {
                if (GetByName(data.Ten) != null)
                {
                    return false;
                }

                dbContext.NguyenLieus.InsertOnSubmit(data);
                dbContext.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }