Example #1
0
 private void dgvSerial_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (dgvSerial.Columns[e.ColumnIndex].Name == "colNgayHetBH")
     {
         if (e.Value.ToString() != "")
         {
             e.Value = TienIch.LayNgayThangVN(Convert.ToDateTime(e.Value.ToString()));
             e.CellStyle.BackColor = Color.Green;
             e.CellStyle.ForeColor = Color.White;
         }
         else
         {
             e.CellStyle.BackColor = Color.Gray;
         }
     }
 }
Example #2
0
        private void XuLyThem()
        {
            if (txtTenSP.Text == "" || txtDonViTinh.Text == "" || txtGiaMua.Text == "" || txtGiaBan.Text == "")
            {
                FormMessage.Show("Vui lòng nhập đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (numBH.Value == 0)
            {
                FormMessage.Show("Tháng bảo hành phải lớn hơn 0!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            clsSanPham_DTO sanPham = new clsSanPham_DTO();

            if (strDuongDanHinh != null && strTenHinh != null)
            {
                try
                {
                    File.Copy(strDuongDanHinh, Application.StartupPath + @"\data\images\products\" + strTenHinh, true);
                    sanPham.Hinh = @"data\images\products\" + strTenHinh;
                }
                catch
                {
                }
            }
            else
            {
                sanPham.Hinh = @"data\images\empty.png";
            }

            sanPham.TenSanPham    = txtTenSP.Text;
            sanPham.DonViTinh     = txtDonViTinh.Text;
            sanPham.GiaMua        = Convert.ToDecimal(TienIch.HuyDinhDangSo(txtGiaMua.Text));
            sanPham.GiaBan        = Convert.ToDecimal(TienIch.HuyDinhDangSo(txtGiaBan.Text));
            sanPham.BaoHanh       = Convert.ToInt16(numBH.Value);
            sanPham.KhuyenMai     = Convert.ToDecimal(txtKhuyenMai.Text == "" ? "0" : txtKhuyenMai.Text);
            sanPham.MaLoaiSanPham = cboLoaiSP.SelectedValue.ToString();
            sanPham.MaHangSanXuat = cboHSX.SelectedValue.ToString();
            sanPham.MoTa          = rtbMota.Text;
            sanPham.GhiChu        = txtGhiChu.Text;

            themSanPham(sanPham);

            this.Close();
        }
Example #3
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (dgvChiTietBH.Rows.Count == 0 || txtTenKH.Text == "")
            {
                FormMessage.Show("Vui lòng nhập đầy đủ thông tin!", "Nhắc nhở", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (bThemKH)
            {
                clsKhachHang_DTO khachHang = new clsKhachHang_DTO();
                khachHang.TenKhachHang = txtTenKH.Text;
                khachHang.SoDT         = txtSoDT.Text;
                khachHang.DiaChi       = txtDiaChi.Text;

                strMaKH = _KhachHangBUS.ThemKhachHang(khachHang);
            }
            clsBaoHanh_DTO baoHanh = new clsBaoHanh_DTO();

            baoHanh.MaKhachHang = strMaKH;
            baoHanh.MaNhanVien  = Program.MA_NV;
            baoHanh.NgayBaoHanh = TienIch.LayNgayThangHienTaiQuocTe();
            string strMaBH = _BaoHanhBUS.ThemBaoHanh(baoHanh);

            List <clsChiTietBaoHanh_DTO> dsChiTiet = new List <clsChiTietBaoHanh_DTO>();

            foreach (DataGridViewRow dgvRow in dgvChiTietBH.Rows)
            {
                clsChiTietBaoHanh_DTO chiTiet = new clsChiTietBaoHanh_DTO();
                chiTiet.MaBaoHanh  = strMaBH;
                chiTiet.MaSerial   = _SerialBUS.LayMaSerial(dgvRow.Cells[1].Value.ToString());
                chiTiet.NgayHenTra = TienIch.LayNgayThangQuocTe(Convert.ToDateTime(dgvRow.Cells[3].Value.ToString()));
                int iTinhTrang = dgvRow.Cells[5].Value.ToString() == "Chưa trả hàng" ? 0 : dgvRow.Cells[5].Value.ToString() == "Đổi hàng" ? 2 : 3;
                chiTiet.TinhTrang = Convert.ToInt16(dgvRow.Cells[5].Value);
                chiTiet.MotaLoi   = dgvRow.Cells[2].Value.ToString();
                chiTiet.GhiChu    = dgvRow.Cells[4].Value.ToString();

                dsChiTiet.Add(chiTiet);
            }
            _ChiTietBaoHanhBUS.ThemChiTietBaoHanh(dsChiTiet, strMaBH);
            FormMessage.Show("Lưu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            LamSach();
        }
Example #4
0
        private void themNV()
        {
            if (txtTenNV.Text == "" || txtTenDangNhap.Text == "" || txtMK.Text == "")
            {
                FormMessage.Show("Vui lòng nhập đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            clsNhanVien_DTO nhanvien = new clsNhanVien_DTO();

            nhanvien.TenNV       = txtTenNV.Text;
            nhanvien.TenDangNhap = txtTenDangNhap.Text;
            nhanvien.MatKhau     = TienIch.MaHoaMatKhau(txtMK.Text);
            nhanvien.SDT         = txtSoDT.Text;
            nhanvien.Email       = txtEmail.Text;
            nhanvien.CMND        = txtCMND.Text;
            nhanvien.DiaChi      = txtDiaChi.Text;

            nhanvien.Quyen = cbbChucVu.SelectedIndex == 0 ? 1 : 0;

            if (DuongDanHinh != null)
            {
                try
                {
                    File.Copy(DuongDanHinh, Application.StartupPath + @"\data\images\users\" + TenHinh, true);
                    nhanvien.Hinh = @"data\images\users\" + TenHinh;
                }

                catch
                {
                }
            }
            else
            {
                nhanvien.Hinh = @"data\images\empty.png";
            }


            themnhanvien(nhanvien);
            this.Close();
        }
Example #5
0
        private string TaoTruyVan()
        {
            string strTruyVan = string.Empty;

            if (chkTenSP.Checked)
            {
                strTruyVan += string.Format("TenSanPham like '%{0}%'", txtTenSP.Text);
            }
            if (chkGiaMua.Checked)
            {
                if (strTruyVan != string.Empty)
                {
                    strTruyVan += " and ";
                }
                strTruyVan += string.Format("GiaMua >= {0} and GiaMua <= {1}", TienIch.HuyDinhDangSo(txtGiaMuaTu.Text), TienIch.HuyDinhDangSo(txtGiaMuaDen.Text));
            }
            if (chkGiaBan.Checked)
            {
                if (strTruyVan != string.Empty)
                {
                    strTruyVan += " and ";
                }
                strTruyVan += string.Format("GiaBan >= {0} and GiaBan <= {1}", TienIch.HuyDinhDangSo(txtGiaMuaTu.Text), TienIch.HuyDinhDangSo(txtGiaMuaDen.Text));
            }
            if (chkLoaiSP.Checked)
            {
                if (strTruyVan != string.Empty)
                {
                    strTruyVan += " and ";
                }
                strTruyVan += string.Format("MaLoaiSanPham = '{0}'", cboLoaiSP.SelectedValue);
            }
            if (chkHSX.Checked)
            {
                if (strTruyVan != string.Empty)
                {
                    strTruyVan += " and ";
                }
                strTruyVan += string.Format("MaHangSanXuat = '{0}'", cboHSX.SelectedValue);
            }
            return(strTruyVan);
        }
Example #6
0
        private void TaiDuLieu()
        {
            dtSanPham = _SanPhamBUS.LayBangSanPham();
            dtSanPham.Columns.Add("TongTriGia", typeof(System.Int64));

            long lSL         = 0;
            long lTongTriGia = 0;

            foreach (DataRow dr in dtSanPham.Rows)
            {
                dr["TongTriGia"] = Convert.ToInt64(dr["SoLuong"]) * Convert.ToInt64(dr["GiaMua"]);
            }
            foreach (DataRow dr in dtSanPham.Rows)
            {
                lSL         += Convert.ToInt64(dr["SoLuong"]);
                lTongTriGia += Convert.ToInt64(dr["TongTriGia"]);
            }

            txtTongSL.Text     = lSL.ToString();
            txtTongTriGia.Text = TienIch.ChuyenSoSangVND(lTongTriGia);

            dgvTonKho.DataSource = dtSanPham;
        }
Example #7
0
        private void frmPhieuXuat_Load(object sender, EventArgs e)
        {
            decimal   dTongCong   = 0;
            DataTable dtPhieuXuat = _PhieuXuatBUS.LayBanInPhieuXuat(strMaPhieu);
            DataTable dtKH        = _PhieuXuatBUS.LayBangKhachHangPX(strMaPhieu);

            foreach (DataRow dr in dtPhieuXuat.Rows)
            {
                dTongCong += Convert.ToDecimal(dr["ThanhTien"]);
            }

            string strLogo      = string.Empty;
            string strTenCongTy = string.Empty;
            string strDiaChi    = string.Empty;
            string strDienThoai = string.Empty;
            string strWebsite   = string.Empty;
            string strTenKH     = dtKH.Rows[0]["TenKhachHang"].ToString();
            string strDiaChiKH  = dtKH.Rows[0]["DiaChi"].ToString();
            string strSoDT      = dtKH.Rows[0]["SoDT"].ToString();

            try
            {
                using (StreamReader sr = new StreamReader("settings.ini"))
                {
                    string str = "";
                    while ((str = sr.ReadLine()) != null)
                    {
                        if (str.Split('=')[0] == "tenCongTy")
                        {
                            strTenCongTy = str.Split('=')[1];
                        }
                        if (str.Split('=')[0] == "diaChi")
                        {
                            strDiaChi = str.Split('=')[1];
                        }
                        if (str.Split('=')[0] == "dienThoai")
                        {
                            strDienThoai = str.Split('=')[1];
                        }
                        if (str.Split('=')[0] == "website")
                        {
                            strWebsite = str.Split('=')[1];
                        }
                        if (str.Split('=')[0] == "logo")
                        {
                            strLogo = "file:///" + Application.StartupPath + "/" + str.Split('=')[1];
                        }
                    }
                    sr.Close();
                }
            }
            catch
            {
                FormMessage.Show("Không tìm thấy file cấu hình!", "Lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.rptPhieuXuat.LocalReport.EnableExternalImages   = true;
            this.rptPhieuXuat.LocalReport.ReportEmbeddedResource = "GUI.rptPhieuXuat.rdlc";
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramLogo", strLogo));
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramTenCongTy", strTenCongTy));
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramDiaChi", strDiaChi));
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramDienThoai", strDienThoai));
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramWebsite", strWebsite));
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramTongCong", string.Format("{0:#,##0} VNĐ", dTongCong)));
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramDocSo", TienIch.ChuyenSoSangChu(dTongCong)));
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramTenKH", strTenKH));
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramDiaChiKH", strDiaChiKH));
            this.rptPhieuXuat.LocalReport.SetParameters(new ReportParameter("paramSoDT", strSoDT));
            this.rptPhieuXuat.LocalReport.DataSources.Add(new ReportDataSource("dsPhieuXuat", dtPhieuXuat));

            this.rptPhieuXuat.RefreshReport();
        }
Example #8
0
        private string TaoCauTruyVan()
        {
            string strTruyVan = string.Empty;

            if (chkNgayGui.Checked)
            {
                strTruyVan += string.Format("NgayBaoHanh >= #{0}# and NgayBaoHanh <= #{1}#", TienIch.LayNgayThangQuocTe(dtpNgayDau.Value), TienIch.LayNgayThangQuocTe(dtpNgayCuoi.Value));
            }
            if (chkLoai.Checked)
            {
                if (strTruyVan != "")
                {
                    strTruyVan += " and ";
                }

                if (cboLoai.SelectedIndex == 0)
                {
                    strTruyVan += "TRUE";
                }
                else if (cboLoai.SelectedIndex == 1)
                {
                    strTruyVan += "TinhTrang=0";
                }
                else if (cboLoai.SelectedIndex == 2)
                {
                    strTruyVan += "TinhTrang=2";
                }
                else if (cboLoai.SelectedIndex == 3)
                {
                    strTruyVan += "TinhTrang=3";
                }
            }
            if (chkMaNCC.Checked)
            {
                if (strTruyVan != "")
                {
                    strTruyVan += " and ";
                }

                strTruyVan += string.Format("MaNhaCungCap='{0}'", txtMaNCC.Text);
            }
            return(strTruyVan);
        }
Example #9
0
        private string TaoCauTruyVan()
        {
            string strTruyVan = string.Empty;

            strTruyVan += string.Format("NgayLap >= #{0}# and NgayLap <= #{1}#", TienIch.LayNgayThangQuocTe(dtpNgayDau.Value), TienIch.LayNgayThangQuocTe(dtpNgayCuoi.Value));

            return(strTruyVan);
        }
Example #10
0
 private void txtTraTruoc_KeyUp(object sender, KeyEventArgs e)
 {
     TienIch.DinhDangSoTextBox(txtTraTruoc);
 }
Example #11
0
        private void GetThongTin()
        {
            string strPregNew = "nsVPovFETgTaPeS+iEsXJlMal2WvNwfgz9kDZSAyEh//Fqb3wxMHeNTr8rAkklj3"; //PatchNew
            string strPreg    = "W3nmTi15jP53j3sfv0JMlaY16oUK5Qric10i7Hvxl/rNlQPcX2Xehp1/+nMT2mAZ"; //PatchOld

            //Get Thông Tin người dùng mới
            List <List <string> > List_strPregPatch = CheckThongTinNguoiDung(strPregNew);

            //kiểm tra xem có dữ liệu người dùng mới không?
            if (List_strPregPatch.Count > 0)
            {
                _mahoa = true;                              //có dữ liệu người dùng mới
            }
            else
            {//không có dữ liệu người dùng mới thì check dữ liệu người dùng cũ
                List_strPregPatch = CheckThongTinNguoiDung(strPreg);
                if (List_strPregPatch.Count > 0)
                {
                    _mahoa = false; //có dữ liệu người dùng cũ
                }
                else                //không có dữ liệu người dùng cũ
                {
                    progressBarTime.Value = 0; lblMSG.Text = "Bạn còn 30 Ngày dùng thử!"; Luu.KFULL = false; Application.Exit();
                }
            }

            string key1 = _mahoa ? "sk29vnbd2988" : "bd";
            string key2 = _mahoa ? "ek29vnkt2988" : "kt";
            string key3 = _mahoa ? "kk29vnkk2988" : "k";

            if (List_strPregPatch[0].Contains(key1) || List_strPregPatch[0].Contains(key2) || List_strPregPatch[0].Contains(key3)) //Kiểm tra REG
            {                                                                                                                      //Đã từng sử dụng
                DateTime hientai = Utils.GetDateTimeNow(Luu.Server);
                DateTime batdau  = DateTime.Parse(_mahoa ? Klib2.KEnDe.ES(GET(key1, List_strPregPatch)) : GET(key1, List_strPregPatch));
                DateTime ketthuc = DateTime.Parse(_mahoa ? Klib2.KEnDe.ES(GET(key2, List_strPregPatch)) : GET(key2, List_strPregPatch));

                string getKey3Tem = _mahoa ? Klib2.KEnDe.ES(GET(key3, List_strPregPatch)) : GET(key3, List_strPregPatch);
                if (TienIch.isTrueKey(getKey3Tem)) //Kiểm tra KEY
                {                                  //KEY Full
                    if ((hientai >= batdau) && (hientai <= ketthuc))
                    {
                        progressBarTime.Value = (int)PHANTRAM(hientai, batdau, ketthuc); lblMSG.Text = "Bạn còn " + (ketthuc - hientai).TotalDays + " Ngày dùng thử!";
                        FULL      = true;
                        Luu.KFULL = true; //this.Hide(); //loginOK();
                    }
                    else
                    {
                        progressBarTime.Value = 100; lblMSG.Text = "Bạn còn 0 Ngày dùng thử!";
                        Luu.KFULL             = false;
                        return; //Show frmDangKy
                    }
                }
                else
                {     //KEY TRIAL
                    if ((hientai >= batdau) && (hientai <= ketthuc))
                    { //Ngày dùng của KEY TRIAL
                        progressBarTime.Value = (int)Math.Round(PHANTRAM(hientai, batdau, ketthuc)); lblMSG.Text = "Bạn còn " + Math.Round((ketthuc - hientai).TotalDays) + " Ngày dùng thử!";
                        Luu.KFULL             = false;
                        return; //Show frmDangKy
                    }
                    else
                    {                                  //Hệt hạn dùng KEY TRIAL
                        progressBarTime.Value = 100; lblMSG.Text = "Bạn còn 0 Ngày dùng thử!"; MessageBox.Show("Hết hạn dùng thử");
                        Luu.KFULL             = false; //Application.Exit();
                        return;
                    }
                }
            }
            else
            {//Chưa từng sử dụng
                DateTime hientai  = Utils.GetDateTimeNow(Luu.Server);
                DateTime tuonglai = hientai.AddDays(30);
                string   now      = hientai.Month + "/" + hientai.Day + "/" + hientai.Year;
                string   future   = tuonglai.Month + "/" + tuonglai.Day + "/" + tuonglai.Year;
                progressBarTime.Value = 0; lblMSG.Text = "Bạn còn 30 Ngày dùng thử!"; Luu.KFULL = false;
                //Lưu lại
                key1 = "sk29vnbd2988";
                key2 = "ek29vnkt2988";
                key3 = "kk29vnkk2988";
                string value_key1 = Klib2.KEnDe.DS(now);
                string value_key2 = Klib2.KEnDe.DS(future);
                string value_key3 = string.Empty;

                List <string> l0 = new List <string>()
                {
                    key1, key2, key3
                };
                List <string> l1 = new List <string>()
                {
                    value_key1, value_key2, value_key3
                };
                List <List <string> > l = new List <List <string> >(); l.Add(l0); l.Add(l1);
                string bientam          = Klib2.KEnDe.MrkKEY; Klib2.KEnDe.MrkKEY = string.Empty;
                string SubK             = Klib2.KEnDe.ES(strPregNew);
                try
                {
                    Klib2.Registry.SetRegistry(SubK, l);
                }
                catch { MessageBox.Show("không thể cấu hình phần mềm, xin vui lòng kiểm tra lại máy tính của bạn!"); Application.Exit(); }
                Klib2.KEnDe.MrkKEY = bientam;
            }
        }
Example #12
0
 private void txtGiaBanDen_KeyUp(object sender, KeyEventArgs e)
 {
     TienIch.DinhDangSoTextBox(txtGiaBanDen);
 }
Example #13
0
 private void TaiDuLieu()
 {
     lblBanHang.Text  = _ThongKeBUS.LaySLBan(TienIch.LayNgayThangHienTaiQuocTe()).ToString();
     lblNhapHang.Text = _ThongKeBUS.LaySLNhap(TienIch.LayNgayThangHienTaiQuocTe()).ToString();
 }
Example #14
0
 private void txtKhuyenMai_KeyPress(object sender, KeyPressEventArgs e)
 {
     TienIch.BuocNhapSo(e);
 }
Example #15
0
        /// <summary>
        /// xử lý hiển thị
        /// </summary>
        public void HienThiTongThe()
        {
            try
            {
                phatsinhno = phatsinhco = sdck = sddk = 0;
                try
                {
                    hienthi = new Entities.SoQuy[pt.Length + pc.Length + bl.Length + bb.Length + hdn.Length + kh.Length + tl.Length + pttkh.Length + pttncc.Length + 1];
                }
                catch { }
                if (kt == false)
                {
                    for (int i = 0; i < sodu.Length; i++)
                    {
                        string monthsodu = sodu[i].NgayKetChuyen.Month.ToString();
                        string yearsodu  = sodu[i].NgayKetChuyen.Year.ToString();
                        if (month == monthsodu && year == yearsodu)
                        {
                            sddk = Convert.ToDouble(sodu[i].SoDuDauKy);
                            break;
                        }
                    }
                }
                int soluong = 0;

                // Phiếu Thu
                for (int i = 0; i < pt.Length; i++)
                {
                    string month1 = pt[i].NgayLap.Month.ToString();
                    string year1  = pt[i].NgayLap.Year.ToString();
                    if (month == month1 && year == year1)
                    {
                        phatsinhno = Convert.ToDouble(pt[i].TongTienThanhToan);
                        string ngaylap = new Common.Utilities().XuLy(2, pt[i].NgayLap.ToShortDateString());
                        hienthi[soluong] = new Entities.SoQuy(ngaylap, pt[i].MaPhieuThu, "1111", "Tiền mặt việt nam",
                                                              Format(phatsinhno), Format(phatsinhco), pt[i].GhiChu, "PhieuThu");
                        soluong++;
                    }
                }
                phatsinhno = phatsinhco = 0;
                // Phiếu Chi
                for (int i = 0; i < pc.Length; i++)
                {
                    string month1 = pc[i].NgayLap.Month.ToString();
                    string year1  = pc[i].NgayLap.Year.ToString();
                    if (month == month1 && year == year1)
                    {
                        phatsinhco = Convert.ToDouble(pc[i].TongTienThanhToan);
                        string ngaylap = new Common.Utilities().XuLy(2, pc[i].NgayLap.ToShortDateString());
                        hienthi[soluong] = new Entities.SoQuy(ngaylap, pc[i].MaPhieuThu, "1111", "Tiền mặt việt nam",
                                                              Format(phatsinhno), Format(phatsinhco), pc[i].GhiChu, "PhieuChi");
                        soluong++;
                    }
                }
                phatsinhno = phatsinhco = 0;
                // Bán Lẻ
                for (int i = 0; i < bl.Length; i++)
                {
                    string month1 = bl[i].NgayBan.Month.ToString();
                    string year1  = bl[i].NgayBan.Year.ToString();
                    if (month == month1 && year == year1)
                    {
                        List <double> bientam = TienIch.TinhDoanhThu(Convert.ToDouble(bl[i].TongTienThanhToan), Convert.ToDouble(bl[i].GiaTriThe), Convert.ToDouble(bl[i].GiaTriTheGiaTri));
                        phatsinhno = bientam[3];  //bl[i].ThanhToanNgay
                        string ngaylap = new Common.Utilities().XuLy(2, bl[i].NgayBan.ToShortDateString());
                        hienthi[soluong] = new Entities.SoQuy(ngaylap, bl[i].MaHDBanHang, "1111", "Tiền mặt việt nam",
                                                              Format(phatsinhno), Format(phatsinhco), bl[i].GhiChu, "BanLe");
                        soluong++;
                    }
                }
                phatsinhno = phatsinhco = 0;
                // Bán Buôn
                for (int i = 0; i < bb.Length; i++)
                {
                    string month1 = bb[i].NgayBan.Month.ToString();
                    string year1  = bb[i].NgayBan.Year.ToString();
                    if (month == month1 && year == year1)
                    {
                        double a = Convert.ToDouble(bb[i].TongTienThanhToan);
                        double b = Convert.ToDouble(bb[i].ThanhToanKhiLapPhieu);
                        if (b > a)
                        {
                            b = a;
                        }
                        phatsinhno = b;
                        string ngaylap = new Common.Utilities().XuLy(2, bb[i].NgayBan.ToShortDateString());
                        hienthi[soluong] = new Entities.SoQuy(ngaylap, bb[i].MaHDBanHang, "1111", "Tiền mặt việt nam",
                                                              Format(phatsinhno), Format(phatsinhco), bb[i].GhiChu, "BanBuon");
                        soluong++;
                    }
                }
                phatsinhno = phatsinhco = 0;
                // Hóa Đơn Nhập
                for (int i = 0; i < hdn.Length; i++)
                {
                    string month1 = hdn[i].NgayNhap.Month.ToString();
                    string year1  = hdn[i].NgayNhap.Year.ToString();
                    if (month == month1 && year == year1)
                    {
                        double a = Convert.ToDouble(hdn[i].TongTien);
                        double b = Convert.ToDouble(hdn[i].ThanhToanNgay);
                        if (b > a)
                        {
                            b = a;
                        }
                        phatsinhco = b;
                        string ngaylap = new Common.Utilities().XuLy(2, hdn[i].NgayNhap.ToShortDateString());
                        hienthi[soluong] = new Entities.SoQuy(ngaylap, hdn[i].MaHoaDonNhap, "1111", "Tiền mặt việt nam",
                                                              Format(phatsinhno), Format(phatsinhco), hdn[i].GhiChu, "HoaDonNhap");
                        soluong++;
                    }
                }
                phatsinhno = phatsinhco = 0;
                // Khách Hàng Trả Lại
                for (int i = 0; i < kh.Length; i++)
                {
                    string month1 = kh[i].NgayNhap.Month.ToString();
                    string year1  = kh[i].NgayNhap.Year.ToString();
                    double a      = Convert.ToDouble(kh[i].TienBoiThuong);
                    double b      = double.Parse(kh[i].ThanhToanNgay);
                    if (b > a)
                    {
                        b = a;
                    }
                    double a1 = b;
                    if (month == month1 && year == year1)
                    {
                        phatsinhco = a1;
                        string ngaylap = new Common.Utilities().XuLy(2, kh[i].NgayNhap.ToShortDateString());
                        hienthi[soluong] = new Entities.SoQuy(ngaylap, kh[i].MaKhachHangTraLai, "1111", "Tiền mặt việt nam",
                                                              Format(phatsinhno), Format(phatsinhco), kh[i].GhiChu, "KHTL");
                        soluong++;
                    }
                }
                phatsinhno = phatsinhco = 0;
                // Trả Lại Nhà Cung Cấp
                for (int i = 0; i < tl.Length; i++)
                {
                    string month1 = tl[i].Ngaytra.Month.ToString();
                    string year1  = tl[i].Ngaytra.Year.ToString();
                    double a      = Convert.ToDouble(tl[i].TienBoiThuong);
                    double b      = Convert.ToDouble(tl[i].ThanhToanNgay);
                    if (b > a)
                    {
                        b = a;
                    }
                    double a1 = b;
                    if (month == month1 && year == year1)
                    {
                        phatsinhno = a1;
                        string ngaylap = new Common.Utilities().XuLy(2, tl[i].Ngaytra.ToShortDateString());
                        hienthi[soluong] = new Entities.SoQuy(ngaylap, tl[i].MaHDTraLaiNCC, "1111", "Tiền mặt việt nam",
                                                              Format(phatsinhno), Format(phatsinhco), tl[i].GhiChu, "TLNCC");
                        soluong++;
                    }
                }
                phatsinhno = phatsinhco = 0;
                // Phiếu thanh toán nhà cung cấp
                for (int i = 0; i < pttncc.Length; i++)
                {
                    string month1 = pttncc[i].NgayLap.Month.ToString();
                    string year1  = pttncc[i].NgayLap.Year.ToString();
                    //double a1 = double.Parse(pttncc[i].NoHienThoi);
                    double a1 = TongThanhToanCuaPhieuThanhToan("NCC", pttncc[i].MaPhieuTTNCC);
                    if (month == month1 && year == year1)
                    {
                        phatsinhco = a1;
                        string ngaylap = new Common.Utilities().XuLy(2, pttncc[i].NgayLap.ToShortDateString());
                        hienthi[soluong] = new Entities.SoQuy(ngaylap, pttncc[i].MaPhieuTTNCC, "1111", "Tiền mặt việt nam",
                                                              Format(phatsinhno), Format(phatsinhco), pttncc[i].GhiChu, "PTTNCC");
                        soluong++;
                    }
                }
                phatsinhno = phatsinhco = 0;
                // Phiếu thanh toán khách hàng
                for (int i = 0; i < pttkh.Length; i++)
                {
                    string month1 = pttkh[i].NgayLap.Month.ToString();
                    string year1  = pttkh[i].NgayLap.Year.ToString();
                    //double a1 = double.Parse(pttkh[i].NoHienThoi);
                    double a1 = TongThanhToanCuaPhieuThanhToan("KH", pttkh[i].MaPhieuTTCuaKH);
                    if (month == month1 && year == year1)
                    {
                        phatsinhno = a1;
                        string ngaylap = new Common.Utilities().XuLy(2, pttkh[i].NgayLap.ToShortDateString());
                        hienthi[soluong] = new Entities.SoQuy(ngaylap, pttkh[i].MaPhieuTTCuaKH, "1111", "Tiền mặt việt nam",
                                                              Format(phatsinhno), Format(phatsinhco), pttkh[i].GhiChu, "PTTKH");
                        soluong++;
                    }
                }

                phatsinhno = phatsinhco = 0;
                List <Entities.SoQuy> l = new List <Entities.SoQuy>();
                foreach (Entities.SoQuy item in hienthi)
                {
                    if (item != null)
                    {
                        l.Add(item);
                    }
                }
                hienthi = l.ToArray();
                //Tính toán
                if (hienthi.Length == 0)
                {//Chỉ có số dư đầu kỳ
                    if (sddk == 0 && sdck == 0)
                    {
                        soquy = new Entities.SoQuy[0];
                    }
                    else
                    {
                        soquy    = new Entities.SoQuy[1];
                        soquy[0] = new Entities.SoQuy("0", "0", "Tổng Cộng", Format(sddk), Format(sdck));
                    }
                }
                else
                {
                    soquy = new Entities.SoQuy[2];
                    for (int i = 0; i < hienthi.Length; i++)
                    {
                        phatsinhco += Convert.ToDouble(hienthi[i].PhatSinhCo);
                        phatsinhno += Convert.ToDouble(hienthi[i].PhatSinhNo);
                        sdck        = sddk + phatsinhno - phatsinhco;
                        soquy[0]    = new Entities.SoQuy("1111", "Tiền mặt việt nam", Format(sddk), Format(phatsinhno), Format(phatsinhco), Format(sdck), "TongHop");
                    }
                    if (phatsinhno == 0 && phatsinhco == 0)
                    {
                        sdck     = sddk + phatsinhno - phatsinhco;
                        soquy[1] = new Entities.SoQuy("0", "0", "Tổng Cộng", Format(sddk), Format(sdck));
                    }
                    else if (phatsinhno == 0 && phatsinhco != 0)
                    {
                        soquy[1] = new Entities.SoQuy("0", Format(phatsinhco), "Tổng Cộng", Format(sddk), Format(sdck));
                    }
                    else if (phatsinhno != 0 && phatsinhco == 0)
                    {
                        soquy[1] = new Entities.SoQuy(Format(phatsinhno), "0", "Tổng Cộng", Format(sddk), Format(sdck));
                    }
                    else if (phatsinhno != 0 && phatsinhco != 0)
                    {
                        soquy[1] = new Entities.SoQuy(Format(phatsinhno), Format(phatsinhco), "Tổng Cộng", Format(sddk), Format(sdck));
                    }
                    a = soquy[1].DuCuoiKy;
                }
                dtgvsoquy.DataSource = soquy;
            }
            catch
            {
                dtgvsoquy.DataSource = new Entities.SoQuy[0];
            }
            finally
            {
                fix();
            }
        }
Example #16
0
 private void frmKey_Load(object sender, EventArgs e)
 {
     textBox1.Text = TienIch.GetMainOrHDD();
     textBox2.Text = string.Empty;
     textBox2.Focus();
 }
Example #17
0
        private string TaoCauTruyVan()
        {
            string strTruyVan = string.Empty;

            if (chkNgay.Checked)
            {
                strTruyVan += string.Format("NgayBaoHanh >= #{0}# and NgayBaoHanh <= #{1}#", TienIch.LayNgayThangQuocTe(dtpNgayDau.Value), TienIch.LayNgayThangQuocTe(dtpNgayCuoi.Value));
            }
            if (chkNV.Checked)
            {
                if (strTruyVan != "")
                {
                    strTruyVan += " and ";
                }
                strTruyVan += string.Format("MaNhanVien = '{0}'", cboNV.SelectedValue);
            }
            if (chkMaKH.Checked)
            {
                if (strTruyVan != "")
                {
                    strTruyVan += " and ";
                }
                strTruyVan += string.Format("MaKhachHang = '{0}'", txtMaKH.Text);
            }
            return(strTruyVan);
        }
Example #18
0
 private void txtGiaSua_KeyPress(object sender, KeyPressEventArgs e)
 {
     TienIch.BuocNhapSo(e);
 }
 public void TongTienNhanVien(DateTime batdau, DateTime ketthuc)
 {
     try
     {
         int sotang = 0;
         for (int i = 0; i < nv.Length; i++)
         {
             for (int j = 0; j < bcnv.Length; j++)
             {
                 DateTime hientai = bcnv[j].NgayBan;
                 if (hientai.Date >= batdau.Date && hientai.Date <= ketthuc.Date && bcnv[j].MaNhanVien == nv[i].MaNhanVien)
                 {
                     sotang++;
                 }
             }
         }
         Entities.BCDTTheoNhanVien[] bcdt = new Entities.BCDTTheoNhanVien[sotang];
         sotang = 0;
         double tongtien;
         for (int i = 0; i < nv.Length; i++)
         {
             tongtien = 0;
             for (int j = 0; j < bcnv.Length; j++)
             {
                 DateTime hientai = bcnv[j].NgayBan;
                 if (hientai.Date >= batdau.Date && hientai.Date <= ketthuc.Date && bcnv[j].MaNhanVien == nv[i].MaNhanVien)
                 {
                     List <double> bientam = TienIch.TinhDoanhThu(bcnv[j].TongTienThanhToan, bcnv[j].GiaTriThe, bcnv[j].GiaTriTheGiaTri);
                     tongtien += bientam[3];   //bcnv[j].ThanhToanNgay
                 }
             }
             if (tongtien != 0)
             {
                 bcdt[sotang] = new Entities.BCDTTheoNhanVien("", nv[i].MaNhanVien, nv[i].TenNhanVien, new Common.Utilities().FormatMoney(tongtien));
                 sotang++;
             }
         }
         hienthi = new Entities.BCDTTheoNhanVien[sotang];
         for (int i = 0; i < hienthi.Length; i++)
         {
             hienthi[i] = bcdt[i];
         }
         //////////////////////////////////////////////Mrk FIX
         List <Entities.BCDTTheoNhanVien> tem0 = new List <Entities.BCDTTheoNhanVien>();
         double tong0 = 0;
         for (int i = 0; i < bcdt.Length; i++)
         {
             if (bcdt[i] == null)
             {
                 break;
             }
             tong0 += double.Parse(bcdt[i].TongTien.Replace(",", ""));
             tem0.Add(bcdt[i]);
         }
         Entities.BCDTTheoNhanVien tem1 = new Entities.BCDTTheoNhanVien();
         tem1.TongTien    = new Common.Utilities().FormatMoney(tong0);
         tem1.TenNhanVien = "Tổng Cộng: ";
         tem0.Add(tem1);
         //foreach (Entities.BCDTTheoNhanVien item in tem0)
         //{
         //    hienthi[i] = item;
         //}
         //////////////////////////////////////////////////////
         //dtgvhienthi.DataSource = hienthi;
         if (tem0.Count == 1 && tem0[0].TenNhanVien.Equals("Tổng Cộng: "))
         {
             //tem0.Remove(tem0[0]);
             tem0 = new List <Entities.BCDTTheoNhanVien>();
         }
         else if (tem0.Count > 1)
         {
             foreach (Entities.BCDTTheoNhanVien item in tem0)
             {
                 if (item.TenNhanVien.Equals("Tổng Cộng: "))
                 {
                     item.GiaTriThe = 0;
                 }
             }
         }
         dtgvhienthi.DataSource = tem0.ToArray();
         if (bcdt.Length > 0)
         {
             tsslexcel.Enabled = tsslPdf.Enabled = tsslWord.Enabled = tsslchitiet.Enabled = true;
         }
         else
         {
             tsslexcel.Enabled = tsslPdf.Enabled = tsslWord.Enabled = tsslchitiet.Enabled = false;
         }
         fix();
     }
     catch
     {
     }
 }