Пример #1
0
        public UcInfo()
        {
            InitializeComponent();

            dataHoaDon = new HoaDon();
            dataHoaDonDetail = new HoaDonDetail();
            dataSP = new DTO.SanPham();
            dataChietKhau = new ChietKhau();

            isUpdate = false;

            if (InitSP() && Init())
            {
                RefreshDataSP();

                RefreshData();

                CreateNewId();

                pbAvatar.Image = Image.FromFile(ConstantResource.SANPHAM_DEFAULT_SP);
            }
            else
            {
                this.Visible = false;
            }
        }
Пример #2
0
        public static bool Delete(HoaDonDetail data, User user)
        {
            try
            {
                if (data != null)
                {
                    HoaDonDetail objDb = GetById(data.Id);

                    if (objDb != null)
                    {
                        dbContext.HoaDonDetails.DeleteOnSubmit(objDb);

                        return true;
                    }
                }
            }
            catch
            {

            }

            CreateSQlConnection();

            return false;
        }
Пример #3
0
        public static bool Update(HoaDonDetail data, User user)
        {
            try
            {
                if (data != null)
                {
                    HoaDonDetail objDb = GetById(data.Id);

                    objDb.IdHoaDon = data.IdHoaDon;
                    objDb.SoLuong = data.SoLuong;
                    objDb.ThanhTien = data.ThanhTien;

                    dbContext.SubmitChanges();
                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
Пример #4
0
        public static bool Insert(HoaDonDetail data, User user)
        {
            try
            {
                dbContext.HoaDonDetails.InsertOnSubmit(data);
                dbContext.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }
Пример #5
0
        private void InsertDataHoaDonDetail(int idHoaDon)
        {
            foreach (ListViewItem lvi in lvThongTin.Items)
            {
                dataHoaDonDetail = new HoaDonDetail();

                dataHoaDonDetail.IdHoaDon = idHoaDon;
                dataHoaDonDetail.IdSanPham = ConvertUtil.ConvertToInt(lvi.SubItems[1].Text);
                dataHoaDonDetail.ChietKhau = ConvertUtil.ConvertToInt(lvi.SubItems[4].Text.Replace(Constant.SYMBOL_DISCOUNT, ""));
                dataHoaDonDetail.SoLuong = ConvertUtil.ConvertToInt(lvi.SubItems[6].Text);
                dataHoaDonDetail.DonGia = ConvertUtil.ConvertToLong(lvi.SubItems[8].Text.Replace(Constant.SYMBOL_LINK_MONEY, string.Empty));
                dataHoaDonDetail.ThanhTien = ConvertUtil.ConvertToLong(lvi.SubItems[9].Text.Replace(Constant.SYMBOL_LINK_MONEY, string.Empty));

                if (HoaDonDetailBus.Insert(dataHoaDonDetail))
                {
                    UpdateDataSP(dataHoaDonDetail.SanPham, dataHoaDonDetail.SoLuong);
                }
                else
                {
                    try
                    {
                        HoaDonDetailBus.Delete(dataHoaDonDetail);
                    }
                    catch
                    {
                        //
                    }

                    MessageBox.Show(Constant.MESSAGE_INSERT_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
            }
        }
Пример #6
0
		private void detach_HoaDonDetails(HoaDonDetail entity)
		{
			this.SendPropertyChanging();
			entity.HoaDon = null;
		}
Пример #7
0
 partial void DeleteHoaDonDetail(HoaDonDetail instance);
Пример #8
0
 partial void UpdateHoaDonDetail(HoaDonDetail instance);
Пример #9
0
 partial void InsertHoaDonDetail(HoaDonDetail instance);
Пример #10
0
		private void attach_HoaDonDetails(HoaDonDetail entity)
		{
			this.SendPropertyChanging();
			entity.SanPham = this;
		}
Пример #11
0
        private bool UpdateDataHoaDonDetail(DTO.HoaDon dataHoaDon)
        {
            foreach (DataGridViewRow row in dgvThongTin.Rows)
            {
                if (!string.IsNullOrEmpty(row.Cells[colId.Name].Value.ToString()))
                {
                    DTO.HoaDonDetail data = HoaDonDetailBus.GetById(ConvertUtil.ConvertToInt(row.Cells[colId.Name].Value));

                    data.SoLuong = ConvertUtil.ConvertToInt(row.Cells[colSoLuong.Name].Value);
                    data.ThanhTien = ConvertUtil.ConvertToLong(row.Cells[colThanhTien.Name].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty));
                    data.GhiChu = row.Cells[colGhiChu.Name].Value == null ? string.Empty : row.Cells[colGhiChu.Name].Value.ToString();

                    if (!HoaDonDetailBus.Update(data, FormMain.user))
                    {
                        return false;
                    }
                }
                else
                {
                    DTO.HoaDonDetail data = new DTO.HoaDonDetail();

                    data.IdHoaDon = dataHoaDon.Id;
                    data.IdSanPham = ConvertUtil.ConvertToInt(row.Cells[colIdSanPham.Name].Value);
                    data.DonGia = ConvertUtil.ConvertToLong(row.Cells[colGia.Name].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty));
                    data.SoLuong = ConvertUtil.ConvertToInt(row.Cells[colSoLuong.Name].Value);
                    data.ThanhTien = ConvertUtil.ConvertToLong(row.Cells[colThanhTien.Name].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty));
                    data.GhiChu = row.Cells[colGhiChu.Name].Value == null ? string.Empty : row.Cells[colGhiChu.Name].Value.ToString();

                    if (!HoaDonDetailBus.Insert(data, FormMain.user))
                    {
                        return false;
                    }
                }
            }

            return true;
        }
Пример #12
0
        public UcInfo(DTO.HoaDonDetail data)
        {
            InitializeComponent();

            dataHoaDonDetail = data;
            dataHoaDon = data.HoaDon;
            dataSP = data.SanPham;
            dataChietKhau = ChietKhauBus.GetByIdSP(data.IdSanPham);
            dataXuatXu = dataSP.XuatXu;

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

            if (HoaDonDetailBus.CheckIfSold(data.IdSanPham))
            {
                tbSoLuong.ReadOnly = true;
            }

            cbChangeMoney.SelectedIndex = 0;

            if (InitSP() && Init())
            {
                tbMaSP.Text = dataSP.MaSanPham;
                cbGroup.Text = dataSP.SanPhamGroup.Ten;
                cbDVTSP.Text = dataSP.DonViTinh;
                tbTenSP.Text = dataSP.Ten;
                tbSize.Text = dataSP.Size;
                cbXuatXu.Text = dataXuatXu == null ? string.Empty : dataXuatXu.Ten;
                tbHieu.Text = dataSP.Hieu;
                tbThoiHan.Text = dataSP.ThoiHan == 0 ? string.Empty : dataSP.ThoiHan.ToString();
                cbDonViThoiHan.Text = dataSP.DonViThoiHan;
                tbMoTa.Text = dataSP.MoTa;

                tbMaNhap.Text = dataHoaDon.MaHoaDon;
                tbGiaNhap.Text = dataSP.GiaMua.ToString(Constant.DEFAULT_FORMAT_MONEY);
                tbSoLuong.Text = data.SoLuong.ToString();
                tbLaiSuat.Text = dataSP.LaiSuat.ToString();
                tbGiaBan.Text = dataSP.GiaBan.ToString(Constant.DEFAULT_FORMAT_MONEY);
                tbGhiChu.Text = dataHoaDon.GhiChu;

                tbChietKhau.Text = dataChietKhau == null ? string.Empty : dataChietKhau.Value.ToString();

                //avatarPath = Path.Combine(File_Function.getFinalFolder(listFolderAvatar), CommonFunc.setAvatarPath(dataSP.MaSanPham, dataSP.CreateDate));

                if (!string.IsNullOrEmpty(dataSP.Avatar))
                {
                    //string sImage = Convert_Function.ConvertByteArrayToString(Convert_Function.ConvertImageToByteArray(Image.FromFile(avatarPath)));
                    pbAvatar.Image = Convert_Function.ConvertByteArrayToImage(Convert_Function.ConvertStringToByteArray(dataSP.Avatar));
                }
                else
                {
                    pbAvatar.Image = Image.FromFile(ConstantResource.SANPHAM_DEFAULT_SP);
                }

                oldDate = dataSP.UpdateDate;
            }
            else
            {
                this.Visible = false;
            }
        }
Пример #13
0
        private void InsertDataHoaDonDetail(int idHoaDon)
        {
            dataHoaDonDetail = new HoaDonDetail();

            dataHoaDonDetail.IdHoaDon = idHoaDon;
            dataHoaDonDetail.IdSanPham = dataSP.Id;
            dataHoaDonDetail.SoLuong = ConvertUtil.ConvertToInt(tbSoLuong.Text);
            dataHoaDonDetail.ThanhTien = ConvertUtil.ConvertToLong(tbThanhTien.Text.Replace(Constant.SYMBOL_LINK_MONEY, string.Empty));

            if (HoaDonDetailBus.Insert(dataHoaDonDetail))
            {
                InsertChietKhau();
            }
            else
            {
                try
                {
                    HoaDonDetailBus.Delete(dataHoaDonDetail);
                }
                catch
                {
                    //
                }

                if (MessageBox.Show(Constant.MESSAGE_INSERT_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    this.Dispose();
                }
            }
        }