Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            long     xe   = long.Parse(comboBox1.SelectedValue.ToString());
            DateTime from = dateTimePickerFROM.Value.Date;
            DateTime to   = dateTimePickerTO.Value.Date;
            var      lst  = DataInstance.Instance().DBContext().CHI_TIEU_DUNG_NOI_BO.Where(u => u.MAXE == xe)
                            .Where(u => u.NGAY_CHI >= from && u.NGAY_CHI <= to)
                            .OrderBy(u => u.NGAY_CHI);
            List <object> list = new List <object>();

            foreach (CHI_TIEU_DUNG_NOI_BO nb in lst)
            {
                list.Add(new
                {
                    NGAY      = nb.NGAY_CHI,
                    KHO       = MKho.GetNamebyID(nb.MAKHO),
                    NOIDUNG   = nb.NOI_DUNG,
                    HANGHOA   = nb.MAHH == -1 ? "" : MHangHoa.GetNameByID(nb.MAHH),
                    SOLUONG   = nb.SO_LUONG,
                    DONGIA    = nb.DON_GIA_BAN,
                    THANHTIEN = nb.TONG_TIEN,
                });
            }
            CrystalReportCHIDUNGCHOXE rpt = new CrystalReportCHIDUNGCHOXE();

            rpt.SetDataSource(list);
            rpt.SetParameterValue("FROM", dateTimePickerFROM.Value);
            rpt.SetParameterValue("TO", dateTimePickerTO.Value);
            rpt.SetParameterValue("COMP", ConstClass.COMPANY_NAME);
            rpt.SetParameterValue("KH", comboBox1.Text);
            crystalReportViewer1.ReportSource = rpt;
            crystalReportViewer1.Zoom(150);
        }
Ejemplo n.º 2
0
Archivo: FChi.cs Proyecto: nttam1/tgas
 private void comboBoxNBXE_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         var      xe  = Int32.Parse(comboBoxNBXE.SelectedValue.ToString());
         var      kho = Int32.Parse(comboBoxKHO.SelectedValue.ToString());
         DateTime now = dateTimePickerdATE.Value.Date;
         var      lst = dbContext.CHI_TIEU_DUNG_NOI_BO.Where(u => u.MAXE == xe)
                        .Where(u => u.MAKHO == kho)
                        .Where(u => u.NGAY_CHI == now);
         List <object> list = new List <object>();
         foreach (CHI_TIEU_DUNG_NOI_BO nb in lst)
         {
             list.Add(new
             {
                 NGAY      = nb.NGAY_CHI,
                 NOIDUNG   = nb.NOI_DUNG,
                 HANGHOA   = nb.MAHH == -1 ? "" : MHangHoa.GetNameByID(nb.MAHH),
                 SOLUONG   = nb.SO_LUONG,
                 DONGIA    = nb.DON_GIA_BAN,
                 THANHTIEN = nb.TONG_TIEN,
             });
         }
         bs_noibo.DataSource                  = list;
         dataGridViewXE.DataSource            = bs_noibo;
         dataGridViewXE.Columns[0].HeaderText = "NGÀY";
         dataGridViewXE.Columns[1].HeaderText = "NỘI DUNG CHI";
         dataGridViewXE.Columns[2].HeaderText = "HÀNG HÓA";
         dataGridViewXE.Columns[3].HeaderText = "SỐ LƯỢNG";
         dataGridViewXE.Columns[4].HeaderText = "ĐƠN GIÁ";
         dataGridViewXE.Columns[5].HeaderText = "THÀNH TIỀN";
     }
     catch (Exception ex)
     {
     }
 }
Ejemplo n.º 3
0
        private void buttonVIEW_Click(object sender, EventArgs e)
        {
            var           _ncc  = long.Parse(comboBoxNCC.SelectedValue.ToString());
            var           _from = dateTimePickerFROM.Value;
            var           _to   = dateTimePickerTO.Value;
            string        note  = "";
            BindingSource bs    = new BindingSource();

            if (checkBoxTRANO.Checked == false)
            {
                bs.DataSource = (from nh in DataInstance.Instance().DBContext().NHAP_HANG
                                 join kho in DataInstance.Instance().DBContext().KHOes on nh.MAKHO equals kho.ID
                                 join ncc in DataInstance.Instance().DBContext().NHA_CUNG_CAP on nh.MANCC equals ncc.ID
                                 join hh in DataInstance.Instance().DBContext().HANG_HOA on nh.MAHH equals hh.ID
                                 where nh.MANCC == _ncc
                                 where nh.NGAY_NHAP >= _from
                                 where nh.NGAY_NHAP <= _to
                                 select new
                {
                    NGAY = nh.NGAY_NHAP,
                    KHO = kho.NAME,
                    HANGHOA = hh.NAME,
                    SOLUONG = nh.SO_LUONG,
                    DONGIA = nh.DON_GIA_MUA,
                    THANHTIEN = nh.SO_LUONG * nh.DON_GIA_MUA
                });
                CrystalReportCHITIETNONCC rpt = new CrystalReportCHITIETNONCC();
                rpt.SetDataSource(bs);
                rpt.SetParameterValue("NCC", comboBoxNCC.Text);
                rpt.SetParameterValue("FROM", _from);
                rpt.SetParameterValue("TO", _to);
                rpt.SetParameterValue("COMP", ConstClass.COMPANY_NAME);
                crystalReportViewer1.ReportSource = rpt;
            }
            else
            {
                List <CThanhToanNCC> lst = new List <CThanhToanNCC>();
                foreach (NHAP_HANG nh in DataInstance.Instance().DBContext().NHAP_HANG
                         .Where(u => u.MANCC == _ncc && u.NGAY_NHAP >= _from && u.NGAY_NHAP <= _to))
                {
                    lst.Add(new CThanhToanNCC
                    {
                        NGAY          = nh.NGAY_NHAP,
                        KHO           = MKho.GetNamebyID(nh.MAKHO),
                        HANGHOA       = MHangHoa.GetNameByID(nh.MAHH),
                        DONGIA        = nh.DON_GIA_MUA,
                        SOLUONG       = nh.SO_LUONG,
                        THANHTIEN     = nh.SO_LUONG * nh.DON_GIA_MUA,
                        TIENTHANHTOAN = 0,
                        CONNO         = 0,
                        THANHTOAN     = "-",
                    });
                }
                foreach (TRA_NO_NCC tn in DataInstance.Instance().DBContext().TRA_NO_NCC
                         .Where(u => u.MANCC == _ncc && u.NGAY_TRA >= _from && u.NGAY_TRA <= _to))
                {
                    lst.Add(new CThanhToanNCC
                    {
                        NGAY          = tn.NGAY_TRA,
                        KHO           = MKho.GetNamebyID(tn.MAKHO),
                        HANGHOA       = "-",
                        DONGIA        = 0,
                        SOLUONG       = 0,
                        TIENTHANHTOAN = tn.TONG_TIEN,
                        CONNO         = 0,
                        THANHTOAN     = "TRẢ NỢ NCC",
                    });
                }
                var  datasource = lst.OrderBy(u => u.NGAY);
                long nodauki    = MNcc.NoTO(_ncc, _from) - MNcc.TraNoTO(_ncc, _from);
                long _nodauki   = nodauki;
                foreach (CThanhToanNCC c in datasource)
                {
                    c.CONNO = nodauki - c.TIENTHANHTOAN + c.THANHTIEN;
                    nodauki = c.CONNO;
                }
                bs.DataSource = lst;
                CrystalReportTHANHTOANNCC rpt = new CrystalReportTHANHTOANNCC();
                rpt.SetDataSource(bs);
                rpt.SetParameterValue("NCC", comboBoxNCC.Text);
                rpt.SetParameterValue("FROM", _from);
                rpt.SetParameterValue("TO", _to);
                rpt.SetParameterValue("COMP", ConstClass.COMPANY_NAME);
                rpt.SetParameterValue("NODAUKI", _nodauki);
                crystalReportViewer1.ReportSource = rpt;
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <CCongNoNew> _datasource = new List <CCongNoNew>();
            string            note        = "";
            BindingSource     bs          = new BindingSource();
            long     MAKH      = long.Parse(comboBox1.SelectedValue.ToString());
            DateTime FROM      = dateTimePickerFROM.Value.Date;
            DateTime TO        = dateTimePickerTO.Value.Date;
            var      xuat_hang = db.XUAT_HANG.Where(u => u.MAKH == MAKH && u.NGAY_XUAT >= FROM && u.NGAY_XUAT <= TO);
            var      thu_no    = db.THU_NO.Where(u => u.MAKH == MAKH && u.NGAY_TRA >= FROM && u.NGAY_TRA <= TO);

            foreach (XUAT_HANG xh in xuat_hang)
            {
                HANG_HOA _hh     = MHangHoa.GetByID(xh.MAHH);
                string   unit    = _hh == null ? "" : _hh.UNIT;
                long     dongia  = _hh == null ? 0 : xh.DON_GIA_BAN;
                long     soluong = _hh == null ? 0 : xh.SO_LUONG;
                _datasource.Add(new CCongNoNew
                {
                    NGAY      = xh.NGAY_XUAT.Value,
                    TRANO     = soluong < 0 ? "Nhập bù" : "",
                    TRATRUOC  = xh.TRA_TRUOC,
                    HANGHOA   = MHangHoa.GetNameByID(xh.MAHH),
                    SOLUONG   = soluong,
                    DONVITINH = unit,
                    DONGIA    = dongia,
                    THANHTIEN = xh.THANH_TIEN,
                    TRAGOC    = 0,
                    TRALAI    = 0,
                    CONNO     = 0
                });
            }

            foreach (THU_NO xh in thu_no)
            {
                _datasource.Add(new CCongNoNew
                {
                    NGAY      = xh.NGAY_TRA,
                    TRATRUOC  = 0,
                    TRANO     = "Trả nợ",
                    HANGHOA   = "",
                    SOLUONG   = 0,
                    DONVITINH = "",
                    DONGIA    = 0,
                    THANHTIEN = 0,
                    TRAGOC    = xh.TIEN_GOC,
                    TRALAI    = xh.TIEN_LAI,
                    CONNO     = 0
                });
            }
            var  datasource = _datasource.OrderBy(u => u.NGAY);
            long no         = checkBoxNODAUKI.Checked == true?MXuatHang.TongNoDauKi(MAKH, FROM) - MThuNo.TongGocDauKi(MAKH, FROM) : 0;

            long nodauki = no;

            foreach (CCongNoNew c in datasource)
            {
                c.CONNO = no + c.THANHTIEN - c.TRATRUOC - c.TRAGOC;
                no      = c.CONNO;
            }

            bs.DataSource = datasource;
            CrystalReportCONGNOKHACHHANG rpt = new CrystalReportCONGNOKHACHHANG();

            rpt.SetDataSource(bs);
            rpt.SetParameterValue("KH", comboBox1.Text);
            rpt.SetParameterValue("FROM", dateTimePickerFROM.Value);
            rpt.SetParameterValue("TO", dateTimePickerTO.Value);
            rpt.SetParameterValue("COMP", ConstClass.COMPANY_NAME);
            rpt.SetParameterValue("NODAUKI", nodauki);
            crystalReportViewer1.ReportSource = rpt;
            crystalReportViewer1.Zoom(150);
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <CCongNoKhachHang> _datasource = new List <CCongNoKhachHang>();
            string        note = "";
            BindingSource bs   = new BindingSource();
            long          MAKH = long.Parse(comboBox1.SelectedValue.ToString());
            DateTime      FROM = dateTimePickerFROM.Value.Date;
            DateTime      TO   = dateTimePickerTO.Value.Date;

            /* Lấy tất cả dữ liệu xuất hàng cho khách hàng này */
            /* Từ ngày đến ngày */
            IQueryable <CCongNoKhachHang> xuat_hang = (from _xh in DataInstance.Instance().DBContext().XUAT_HANG
                                                       join _kho in DataInstance.Instance().DBContext().KHOes on _xh.MAKHO equals _kho.ID
                                                       //join _hh in DataInstance.Instance().DBContext().HANG_HOA on _xh.MAHH equals _hh.ID
                                                       where _xh.MAKH == MAKH
                                                       where _xh.NGAY_XUAT >= FROM && _xh.NGAY_XUAT <= TO
                                                       orderby _xh.NGAY_XUAT ascending
                                                       select new CCongNoKhachHang
            {
                ID = (int)_xh.ID,
                NGAY = _xh.NGAY_XUAT.Value,
                KHO = _kho.NAME,
                HANGHOAID = _xh.MAHH,
                //HANGHOA = _hh.NAME,
                SOLUONG = _xh.SO_LUONG,
                DONGIABAN = _xh.DON_GIA_BAN,
                THANHTIEN = _xh.THANH_TIEN,
                TRATRUOC = _xh.TRA_TRUOC,
                LAISUAT = _xh.LAI_SUAT,
                LAI = 0,
                TRAGOC = 0,
                TRALAI = 0,
                CONNO = 0
            });

            note = "CHI TIẾT LÃI KHÁCH HÀNG";
            DateTime now = dateTimePickerTO.Value.Date;

            /* Không sử dụng dữ liệu từ thu nợ */
            foreach (CCongNoKhachHang row in xuat_hang)
            {
                //double lai = Utility.Lai(row.NGAY, now, row.LAISUAT, row.THANHTIEN - row.TRATRUOC);
                double lai     = MXuatHang.GetLai(row.ID, now);
                string HangHoa = MHangHoa.GetNameByID(row.HANGHOAID);
                _datasource.Add(new CCongNoKhachHang()
                {
                    NGAY      = row.NGAY,
                    KHO       = row.KHO,
                    HANGHOA   = HangHoa,
                    SOLUONG   = row.SOLUONG,
                    DONGIABAN = row.DONGIABAN,
                    THANHTIEN = row.THANHTIEN,
                    TRATRUOC  = row.TRATRUOC,
                    LAISUAT   = row.LAISUAT * 100,
                    /* Cần tính lãi */
                    LAI    = lai,
                    TRAGOC = 0,
                    TRALAI = 0,
                    CONNO  = row.THANHTIEN + (long)lai - row.TRATRUOC
                });
            }
            //}
            bs.DataSource = _datasource;
            CrystalReportCHITIETLAIKHACHHANG rpt = new CrystalReportCHITIETLAIKHACHHANG();

            rpt.SetDataSource(bs);
            rpt.SetParameterValue("KH", comboBox1.Text);
            rpt.SetParameterValue("FROM", dateTimePickerFROM.Value);
            rpt.SetParameterValue("TO", dateTimePickerTO.Value);
            rpt.SetParameterValue("COMP", ConstClass.COMPANY_NAME);
            rpt.SetParameterValue("NOTE", note);
            crystalReportViewer1.ReportSource = rpt;
            crystalReportViewer1.Zoom(150);
        }