Exemple #1
0
        private void InsertData()
        {
            data = new DTO.XuatXu();

            data.Ten = tbTen.Text;
            data.DiaChi = tbDiaChi.Text;
            data.DienThoai = tbDienThoai.Text;
            data.DTDD = tbDTDD.Text;
            data.Fax = tbFax.Text;
            data.Email = tbEmail.Text;
            data.GhiChu = tbGhiChu.Text;

            if (XuatXuBus.Insert(data, FormMain.user))
            {
                this.Dispose();
            }
            else
            {
                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();
                }
            }
        }
Exemple #2
0
 private void LoadData(DTO.SanPham data)
 {
     lbMa.Text = data.MaSanPham;
     lbGroup.Text = data.SanPhamGroup.Ten;
     lbTen.Text = data.Ten;
     lbMoTa.Text = data.MoTa;
     lbDVT.Text = data.DonViTinh;
     lbSize.Text = data.Size;
     lbHieu.Text = data.Hieu;
     dataXuatXu = data.XuatXu;
     lbXuatXu.Text = dataXuatXu == null ? string.Empty : dataXuatXu.Ten;
     lbThoiHan.Text = data.ThoiHan == 0 ? string.Empty : (data.ThoiHan.Value.ToString() + " " + data.DonViThoiHan);
 }
Exemple #3
0
        public UcInfo()
        {
            InitializeComponent();

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

            if (Init())
            {
                RefreshData();
            }
            else
            {
                this.Visible = false;
            }
        }
Exemple #4
0
        public UcInfo(DTO.XuatXu data)
        {
            InitializeComponent();

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

            if (Init())
            {
                tbTen.Text = data.Ten;
                tbDiaChi.Text = data.DiaChi;
                tbDienThoai.Text = data.DienThoai;
                tbDTDD.Text = data.DTDD;
                tbFax.Text = data.Fax;
                tbEmail.Text = data.Email;
                tbGhiChu.Text = data.GhiChu;
            }
            else
            {
                this.Visible = false;
            }
        }
Exemple #5
0
        public static bool Delete(XuatXu data, User user)
        {
            try
            {
                if (data != null)
                {
                    data.UpdateBy = user.UserName;
                    data.UpdateDate = DateTime.Now;

                    dbContext.XuatXus.DeleteOnSubmit(data);
                    dbContext.SubmitChanges();

                    return true;
                }
            }
            catch
            {
                //return false;
            }

            CreateSQlConnection();

            return false;
        }
Exemple #6
0
 public static bool Delete(XuatXu data, User user)
 {
     return XuatXuDao.Delete(data, user);
 }
Exemple #7
0
        public static bool Update(XuatXu data, User user)
        {
            try
            {
                if (data != null)
                {
                    data.UpdateBy = user.UserName;
                    data.UpdateDate = DateTime.Now;

                    dbContext.SubmitChanges();
                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
Exemple #8
0
        public static bool Insert(XuatXu data, User user)
        {
            try
            {
                data.CreateBy = data.UpdateBy = user.UserName;
                data.CreateDate = data.UpdateDate = DateTime.Now;

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

                return true;
            }
            catch
            {
                return false;
            }
        }
Exemple #9
0
 partial void DeleteXuatXu(XuatXu instance);
Exemple #10
0
        private void cbXuatXu_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataXuatXu = XuatXuBus.GetById(ConvertUtil.ConvertToInt(((CommonComboBoxItems)cbXuatXu.SelectedItem).Value));

            tbThoiHan.Focus();
        }
Exemple #11
0
 partial void InsertXuatXu(XuatXu instance);
Exemple #12
0
        private void LoadDataSP(DTO.SanPham data)
        {
            lbMa.Text = data.MaSanPham;
            lbGroup.Text = data.SanPhamGroup.Ten;
            lbTen.Text = data.Ten;
            lbMoTa.Text = data.MoTa;
            lbSoLuong.Text = data.SoLuong.ToString();
            lbDVT.Text = data.DonViTinh;

            DTO.ChietKhau dataCK = ChietKhauBus.GetByIdSP(data.Id);

            if (dataCK != null)
            {
                lbChietKhau.Text = dataCK.Value == 0 ? string.Empty : (dataCK.Value.ToString() + Constant.SYMBOL_DISCOUNT);
            }

            lbSize.Text = data.Size;
            lbHieu.Text = data.Hieu;

            dataXuatXu = data.XuatXu;
            lbXuatXu.Text = dataXuatXu == null ? string.Empty : dataXuatXu.Ten;

            lbThoiHan.Text = data.ThoiHan == 0 ? string.Empty : (data.ThoiHan.Value.ToString() + " " + data.DonViThoiHan);

            DateTime usedDay = data.CreateDate;

            switch (data.DonViThoiHan)
            {
                case Constant.DEFAULT_TYPE_DAY:
                    usedDay = data.CreateDate.AddDays(data.ThoiHan.Value);
                    break;

                case Constant.DEFAULT_TYPE_MONTH:
                    usedDay = data.CreateDate.AddMonths(data.ThoiHan.Value);
                    break;

                case Constant.DEFAULT_TYPE_YEAR:
                    usedDay = data.CreateDate.AddYears(data.ThoiHan.Value);
                    break;

                default:
                    usedDay = data.CreateDate.AddDays(data.ThoiHan.Value);
                    break;
            }

            lbNgayNhap.Text = data.CreateDate.ToString(Constant.DEFAULT_DATE_FORMAT);

            if (data.ThoiHan.Value != 0)
            {
                lbNgayHetHan.Text = usedDay.ToString(Constant.DEFAULT_DATE_FORMAT);

                if (data.SoLuong != 0)
                {
                    switch (CommonFunc.IsExpired(data.CreateDate, Constant.DEFAULT_WARNING_DAYS_EXPIRED,
                        data.ThoiHan.Value, data.DonViThoiHan))
                    {
                        case Constant.DEFAULT_STATUS_USED_DATE_NEAR:
                            lbNgayHetHan.ForeColor = Color.Orange;
                            break;

                        case Constant.DEFAULT_STATUS_USED_DATE_END:
                            lbNgayHetHan.ForeColor = Color.Red;
                            break;
                    }
                }
            }

            if (!string.IsNullOrEmpty(data.Avatar))
            {
                pbAvatar.Image = Convert_Function.ConvertByteArrayToImage(Convert_Function.ConvertStringToByteArray(data.Avatar));
            }
            else
            {
                pbAvatar.Image = Image.FromFile(ConstantResource.SANPHAM_DEFAULT_SP);
            }
        }
Exemple #13
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;
            }
        }
Exemple #14
0
 private void cbXuatXu_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(cbXuatXu.Text))
     {
         dataXuatXu = null;
     }
 }
Exemple #15
0
 public static bool Insert(XuatXu data, User user)
 {
     return XuatXuDao.Insert(data, user);
 }
Exemple #16
0
 partial void UpdateXuatXu(XuatXu instance);
Exemple #17
0
 public static bool Update(XuatXu data, User user)
 {
     return XuatXuDao.Update(data, user);
 }
Exemple #18
0
        private bool UpdateDataSP()
        {
            dataSP = SanPhamBus.GetById(dataHoaDonDetail.IdSanPham);

            dataSP.MaSanPham = tbMaSP.Text;
            dataSP.Ten = tbTenSP.Text;
            dataSP.SanPhamGroup = SanPhamGroupBus.GetById(ConvertUtil.ConvertToInt(((CommonComboBoxItems)cbGroup.SelectedItem).Value));

            if (cbXuatXu.SelectedItem != null)
            {
                dataXuatXu = XuatXuBus.GetById(ConvertUtil.ConvertToInt(((CommonComboBoxItems)cbXuatXu.SelectedItem).Value));
            }
            else
            {
                dataXuatXu = null;
            }

            dataSP.XuatXu = dataXuatXu;
            dataSP.MoTa = tbMoTa.Text;
            dataSP.DonViTinh = tbDonViTinh.Text;
            dataSP.Hieu = tbHieu.Text;
            dataSP.Size = tbSize.Text;
            dataSP.ThoiHan = ConvertUtil.ConvertToByte(tbThoiHan.Text);
            dataSP.DonViThoiHan = cbDonViThoiHan.Text;

            if (SanPhamBus.Update(dataSP, FormMain.user))
            {
                return true;
            }
            else
            {
                if (MessageBox.Show(Constant.MESSAGE_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    this.Dispose();
                }
            }

            return false;
        }