示例#1
0
        public UcInfo(DTO.KhachHang data)
        {
            InitializeComponent();

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

            if (Init())
            {
                tbTen.Text = data.Ten;
                tbDiaChi.Text = data.DiaChi;
                tbDTDD.Text = data.DTDD;
                tbEmail.Text = data.Email;
                tbGhiChu.Text = data.GhiChu;

                dtpDOB.Value = data.DOB.HasValue ? data.DOB.Value : DateTime.Now;

                cbGioiTinh.Text = data.GioiTinh;
                cbGroup.Text = data.KhachHangGroup.Ten;

                CreateNewIdKH(false);
            }
            else
            {
                this.Visible = false;
            }
        }
示例#2
0
        public static bool Delete(KhachHang data, User user)
        {
            try
            {
                if (data != null)
                {
                    KhachHang objDb = GetById(data.Id);

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

                        return true;
                    }
                }
            }
            catch
            {

            }

            CreateSQlConnection();

            return false;
        }
示例#3
0
        public UcInfo(DTO.KhachHang data)
        {
            InitializeComponent();

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

            if (Init())
            {
                tbTen.Text = data.Ten;
                tbDiem.Text = data.TichLuy.ToString(Constant.DEFAULT_FORMAT_MONEY);
                tbDiaChi.Text = data.DiaChi;
                tbDienThoai.Text = data.DienThoai;
                tbDTDD.Text = data.DTDD;
                tbFax.Text = data.Fax;
                tbEmail.Text = data.Email;
                tbCMND.Text = data.CMND;
                tbNoiCap.Text = data.NoiCap;
                tbGhiChu.Text = data.GhiChu;

                dtpDOB.Value = data.DOB.HasValue ? data.DOB.Value : DateTime.Now;
                dtpNgayCap.Value = data.NgayCap.HasValue ? data.NgayCap.Value : DateTime.Now;

                cbGioiTinh.Text = data.GioiTinh;
                cbGroup.Text = data.KhachHangGroup.Ten;

                CreateNewIdKH(false);
            }
            else
            {
                this.Visible = false;
            }
        }
示例#4
0
        public UcInfo()
        {
            InitializeComponent();

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

            if (Init())
            {
                RefreshData();
            }
            else
            {
                this.Visible = false;
            }
        }
示例#5
0
        private void cbMaKH_Leave(object sender, EventArgs e)
        {
            if (cbMaKH.SelectedItem != null)
            {
                dataKH = KhachHangBus.GetById(ConvertUtil.ConvertToInt(((CommonComboBoxItems)cbMaKH.SelectedItem).Value));

                if (dataKH != null)
                {
                    tbTenKH.Text = dataKH.Ten;
                }
            }
            else
            {
                dataKH = null;
                tbTenKH.Text = string.Empty;
            }
        }
示例#6
0
        private void cbMaKH_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataKH = KhachHangBus.GetById(ConvertUtil.ConvertToInt(((CommonComboBoxItems)cbMaKH.SelectedItem).Value));

            tbTenKH.Text = dataKH == null ? string.Empty : dataKH.Ten;
            tbTichLuy.Text = dataKH.TichLuy == 0 ? "0" : dataKH.TichLuy.ToString();

            tbTienThanhToan.ReadOnly = false;

            GetInfoSP();

            ValidateHoanTat();
        }
示例#7
0
        private void cbMaKH_Leave(object sender, EventArgs e)
        {
            if (cbMaKH.SelectedItem != null)
            {
                dataKH = KhachHangBus.GetById(ConvertUtil.ConvertToInt(((CommonComboBoxItems)cbMaKH.SelectedItem).Value));

                if (dataKH != null)
                {
                    tbTienThanhToan.ReadOnly = false;
                    tbTenKH.Text = dataKH.Ten;
                    tbTichLuy.Text = dataKH.TichLuy == 0 ? "0" : dataKH.TichLuy.ToString();
                }
            }
            else
            {
                dataKH = null;
                tbTienThanhToan.ReadOnly = true;
                tbTienThanhToan.Text = string.Empty;
                tbTenKH.Text = string.Empty;
                tbTichLuy.Text = string.Empty;
            }
        }
示例#8
0
 partial void DeleteKhachHang(KhachHang instance);
示例#9
0
 partial void UpdateKhachHang(KhachHang instance);
示例#10
0
        public static bool Insert(KhachHang data, User user)
        {
            try
            {
                data.CreateBy = data.UpdateBy = user.UserName;
                data.CreateDate = data.UpdateDate = DateTime.Now;

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

                return true;
            }
            catch
            {
                return false;
            }
        }
示例#11
0
        public static bool Update(KhachHang data, User user)
        {
            try
            {
                if (data != null)
                {
                    dbContext.SubmitChanges();
                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
示例#12
0
        private void cbMaKH_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataKH = KhachHangBus.GetById(ConvertUtil.ConvertToInt(((CommonComboBoxItems)cbMaKH.SelectedItem).Value));

            tbTenKH.Text = dataKH == null ? string.Empty : dataKH.Ten;
        }
示例#13
0
        private void InitTraSP()
        {
            pnInfoThu.Visible = false;

            listHoaDonDetail = HoaDonDetailBus.GetListByIdHoaDon(dataHoaDon.Id);
            dataUser = dataHoaDon.User;
            dataKH = dataHoaDon.KhachHang;

            tbMaHDTraSP.Text = dataHoaDon.MaHoaDon;
            tbNguoiBanTraSP.Text = dataUser == null ? string.Empty : dataUser.UserName;
            tbKhachHangTraSP.Text = dataKH == null ? string.Empty : dataKH.MaKhachHang + Constant.SYMBOL_LINK_STRING + dataKH.Ten;
            tbGhiChuTraSP.Text = dataHoaDon.GhiChu;

            lbNgayGioTraSP.Text = dataHoaDon.CreateDate.ToString(Constant.DEFAULT_DATE_TIME_FORMAT);

            long totalDiscount = 0;

            foreach (DTO.HoaDonDetail detail in listHoaDonDetail)
            {
                Color color = Color.Black;
                ListViewItem lvi = new ListViewItem();
                lvi.UseItemStyleForSubItems = false;

                if (detail.IsSendBack)
                {
                    color = Color.Red;
                }

                lvi.SubItems.Add(detail.Id.ToString(), color, Color.Transparent, this.Font);
                lvi.SubItems.Add((lvThongTinTraSP.Items.Count + 1).ToString(), color, Color.Transparent, this.Font);
                lvi.SubItems.Add(detail.SanPham.MaSanPham + Constant.SYMBOL_LINK_STRING + detail.SanPham.Ten,
                    color, Color.Transparent, this.Font);

                if (detail.HoaDon.IsCKTongHD)
                {
                    totalDiscount = detail.HoaDon.TienChietKhau;
                    lvi.SubItems.Add(string.Empty);
                    lvi.SubItems.Add(string.Empty);
                }
                else if (detail.ChietKhau != 0)
                {
                    long money = (detail.ChietKhau * detail.SanPham.GiaBan / 100) * detail.SoLuong;

                    if (detail.HoaDon.IsCKTichLuy)
                    {
                        lvThongTinTraSP.Columns[5].Text = "Điểm CK";
                        money = money / Constant.DEFAULT_CHANGE_RATE;
                        totalDiscount += money;
                    }
                    else
                    {
                        lvThongTinTraSP.Columns[5].Text = "Tiền CK";
                        totalDiscount += money;
                    }

                    lvi.SubItems.Add(detail.ChietKhau.ToString() + Constant.SYMBOL_DISCOUNT,
                        color, Color.Transparent, this.Font);
                    lvi.SubItems.Add(money.ToString(Constant.DEFAULT_FORMAT_MONEY),
                        color, Color.Transparent, this.Font);
                }
                else
                {
                    lvi.SubItems.Add(string.Empty);
                    lvi.SubItems.Add(string.Empty);
                }

                lvi.SubItems.Add(detail.SoLuong.ToString(), color, Color.Transparent, this.Font);
                lvi.SubItems.Add(detail.SanPham.DonViTinh, color, Color.Transparent, this.Font);
                lvi.SubItems.Add(detail.SanPham.GiaBan.ToString(Constant.DEFAULT_FORMAT_MONEY),
                    color, Color.Transparent, this.Font);
                lvi.SubItems.Add(detail.ThanhTien.ToString(Constant.DEFAULT_FORMAT_MONEY),
                    color, Color.Transparent, this.Font);

                lvThongTinTraSP.Items.Add(lvi);

                if (!detail.IsSendBack)
                {
                    if (detail.HoaDon.IsCKTichLuy)
                    {
                        dgvTraSP.Rows.Add(lvi.SubItems[1].Text, lvi.SubItems[2].Text, lvi.SubItems[3].Text,
                            lvi.SubItems[4].Text, 0, 0, lvi.SubItems[7].Text,
                            lvi.SubItems[8].Text, 0);
                    }
                    else
                    {
                        dgvTraSP.Rows.Add(lvi.SubItems[1].Text, lvi.SubItems[2].Text, lvi.SubItems[3].Text,
                            0, 0, 0, lvi.SubItems[7].Text,
                            lvi.SubItems[8].Text, 0);

                        dgvTraSP.Columns[colCK.Name].Visible = false;
                        dgvTraSP.Columns[colDiemCK.Name].Visible = false;
                    }
                }
            }

            tbTongCKTraSP.Text = totalDiscount.ToString(Constant.DEFAULT_FORMAT_MONEY);
            tbTongHDTraSP.Text = dataHoaDon.ThanhTien.ToString(Constant.DEFAULT_FORMAT_MONEY);
        }
示例#14
0
        public static bool Update(KhachHang data, User user)
        {
            try
            {
                if (data != null)
                {
                    data.UpdateBy = user.UserName;
                    data.UpdateDate = DateTime.Now;

                    dbContext.SubmitChanges();
                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
示例#15
0
 private void cbMaKH_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(cbMaKH.Text))
     {
         dataKH = null;
     }
 }
示例#16
0
        private void RefreshData()
        {
            totalMoney = 0;
            totalDiscount = 0;

            tbNguoiBan.Text = FormMain.user.UserName;
            tbGhiChu.Text = string.Empty;

            tbSoLuong.Text = "1";
            tbChietKhau.Text = string.Empty;

            dtpNgayGio.Value = DateTime.Now;
            dtpNgayGio.CustomFormat = Constant.DEFAULT_DATE_TIME_FORMAT;
            lbNgayGio.Text = dtpNgayGio.Value.ToString(Constant.DEFAULT_DATE_TIME_FORMAT);

            cbMaSP.SelectedIndex = cbMaSP.Items.Count > 0 ? 0 : -1;
            cbStatus.SelectedIndex = cbStatus.Items.Count > 0 ? 0 : -1;
            cbMaKH.Text = string.Empty;

            dataKH = null;
            tbTienThanhToan.ReadOnly = true;

            tbTenKH.Text = string.Empty;
            tbTichLuy.Text = string.Empty;
            tbSuDung.Text = string.Empty;
            tbTienSuDung.Text = string.Empty;
            tbTienHoiLai.Text = string.Empty;
            tbTienThanhToan.Text = string.Empty;
            tbTongCK.Text = string.Empty;
            tbTongHoaDon.Text = string.Empty;

            rbTichLuy.Checked = true;
            chbCKTongHD.Checked = false;

            //foreach (ListViewItem lvi in lvThongTin.Items)
            //{
            //    RestoreSanPham(ConvertUtil.ConvertToInt(lvi.SubItems[1].Text));
            //}

            lvThongTin.Items.Clear();

            pbXoa.Enabled = false;
            pbXoa.Image = Image.FromFile(ConstantResource.CHUC_NANG_ICON_DELETE_DISABLE);

            CreateNewId();

            ValidateHoanTat();
        }
示例#17
0
		private void attach_KhachHangs(KhachHang entity)
		{
			this.SendPropertyChanging();
			entity.KhachHangGroup = this;
		}
示例#18
0
        public static bool Insert(KhachHang data, User user)
        {
            try
            {
                dbContext.KhachHangs.InsertOnSubmit(data);
                dbContext.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }
示例#19
0
		private void detach_KhachHangs(KhachHang entity)
		{
			this.SendPropertyChanging();
			entity.KhachHangGroup = null;
		}
示例#20
0
        private void LoadData(DTO.HoaDon data)
        {
            listHoaDonDetail = HoaDonDetailBus.GetListByIdHoaDon(data.Id);
            dataUser = data.User;
            dataKH = data.KhachHang;

            lbMaHD.Text = data.MaHoaDon;
            lbNguoiBan.Text = dataUser == null ? string.Empty : dataUser.UserName;
            lbKhachHang.Text = dataKH == null ? string.Empty : (dataKH.MaKhachHang + Constant.SYMBOL_LINK_STRING + dataKH.Ten);
            lbNgayGio.Text = data.CreateDate.ToString(Constant.DEFAULT_DATE_TIME_FORMAT);
            lbStatusCK.Text = data.IsCKTichLuy ? Constant.DEFAULT_INDIRECT_DISCOUNT : Constant.DEFAULT_DIRECT_DISCOUNT;
            lbGhiChu.Text = data.GhiChu;

            lvThongTin.Columns[5].Text = data.IsCKTichLuy ? "Điểm CK" : "Tiền CK";

            long totalDiscount = 0;

            foreach (DTO.HoaDonDetail detail in listHoaDonDetail)
            {
                ListViewItem lvi = new ListViewItem();

                lvi.SubItems.Add(detail.SanPham.Id.ToString());
                lvi.SubItems.Add((lvThongTin.Items.Count + 1).ToString());
                lvi.SubItems.Add(detail.SanPham.MaSanPham + Constant.SYMBOL_LINK_STRING + detail.SanPham.Ten);

                if (detail.ChietKhau != 0)
                {
                    long money = (detail.ChietKhau * detail.SanPham.GiaBan / 100) * detail.SoLuong;

                    totalDiscount += data.IsCKTichLuy ? money / 100 : money;

                    lvi.SubItems.Add(detail.ChietKhau.ToString() + Constant.SYMBOL_DISCOUNT);
                    lvi.SubItems.Add((data.IsCKTichLuy ? money / 100 : money).ToString(Constant.DEFAULT_FORMAT_MONEY));
                }
                else
                {
                    lvi.SubItems.Add(string.Empty);
                    lvi.SubItems.Add(string.Empty);
                }

                lvi.SubItems.Add(detail.SoLuong.ToString());
                lvi.SubItems.Add(detail.SanPham.DonViTinh);
                lvi.SubItems.Add(detail.SanPham.GiaBan.ToString(Constant.DEFAULT_FORMAT_MONEY));
                lvi.SubItems.Add(detail.ThanhTien.ToString(Constant.DEFAULT_FORMAT_MONEY));

                lvThongTin.Items.Add(lvi);
            }

            lbTongCK.Text = data.IsCKTongHD ? data.TienChietKhau.ToString(Constant.DEFAULT_FORMAT_MONEY) : totalDiscount.ToString(Constant.DEFAULT_FORMAT_MONEY);
            lbTongHD.Text = data.ThanhTien.ToString(Constant.DEFAULT_FORMAT_MONEY);
            lbTienSuDung.Text = data.SuDung == 0 ? string.Empty : data.SuDung.ToString(Constant.DEFAULT_FORMAT_MONEY);
            lbTienThanhToan.Text = (data.ThanhTien - data.SuDung) == 0 ? string.Empty :
                (data.ThanhTien - data.SuDung).ToString(Constant.DEFAULT_FORMAT_MONEY);
        }
示例#21
0
 partial void InsertKhachHang(KhachHang instance);