Esempio n. 1
0
        private void InBienBanQuyetToan()
        {
            if (cmbPhuongThuc.Value == null || cmbPhuongThuc.Value + "" == "0")
            {
                return;
            }
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int strMadviqly            = int.Parse(session.User.ma_dviqly);

            DataTable dt = new DataTable();

            CBDN.Class.InBienBanQT inBienBan = new CBDN.Class.InBienBanQT();
            string strGiao = "", strNhan = "", strGDNhan = "", strGDGiao = "";

            int donvi      = strMadviqly;
            int phuongthuc = int.Parse(cmbPhuongThuc.Value + "");

            if (strMadviqly == 2)
            {
                if (phuongthuc != 0)
                {
                    donvi      = int.Parse(db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(cmbPhuongThuc.Value + "")).IDMADVIQLY.Replace(",2,", "").Replace(",", ""));
                    phuongthuc = 0;
                }
            }

            dt = inBienBan.InBienBanQuyetToan(phuongthuc, donvi, int.Parse(cmbThang.Value + ""), int.Parse(cmbNam.Value + ""), ref strGiao, ref strNhan, ref strGDNhan, ref strGiao);

            MTCSYT.Report.InBienBanQT report = new MTCSYT.Report.InBienBanQT(dt, "" + cmbThang.Value, "" + cmbNam.Value, false, false, "", "", strGiao, strNhan, "", "", strGDNhan, strGDGiao);
            ReportViewer2.Report = report;

            ReportToolbar2.ReportViewer = ReportViewer2;
        }
Esempio n. 2
0
        private void InBienBanQuyetToan()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int strMadviqly            = int.Parse(session.User.ma_dviqly);

            DataTable dt = new DataTable();

            CBDN.Class.InBienBanQT inBienBan = new CBDN.Class.InBienBanQT();
            string strGiao = "", strNhan = "", strGDNhan = "", strGDGiao = "";

            int donvi      = strMadviqly;
            // int phuongthuc = int.Parse(cmbPhuongThuc.Value + "");
            int       phuongthuc = 0;
            DataTable dsdt = new DataTable();

            dsdt.Columns.Add("STT");
            dsdt.Columns.Add("Ten_Cty");

            dsdt.Columns.Add("B1_TieuThu");
            dsdt.Columns.Add("B2_TieuThu");
            dsdt.Columns.Add("B3_TieuThu");
            dsdt.Columns.Add("Tong_TieuThu");
            dsdt.Columns.Add("B1", typeof(decimal));
            dsdt.Columns.Add("B2", typeof(decimal));
            dsdt.Columns.Add("B3", typeof(decimal));
            dsdt.Columns.Add("Tong", typeof(decimal));
            dsdt.Columns.Add("Tyle_B1", typeof(decimal));
            dsdt.Columns.Add("Tyle_B2", typeof(decimal));
            dsdt.Columns.Add("Tyle_B3", typeof(decimal));
            int     j  = 0;
            decimal B1 = 0;
            decimal B2 = 0;
            decimal B3 = 0;

            for (int i = 11; i < 38; i++)
            {
                j++;
                donvi = i;
                var TenDonvi = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == donvi);
                var Ten      = TenDonvi.TEN_DVIQLY;
                dt = inBienBan.InBienBanQuyetToan(phuongthuc, donvi, int.Parse(cmbThang.Value + ""), int.Parse(cmbNam.Value + ""), ref strGiao, ref strNhan, ref strGDNhan, ref strGDGiao);

                /*var B1_TieuThu1 = dt.Rows[0]["B1_TieuThu1"] + "";
                 * var B2_TieuThu1 = dt.Rows[0]["B2_TieuThu1"] + "";
                 * var B3_TieuThu1 = dt.Rows[0]["B3_TieuThu1"] + "";
                 */
                string B1_TieuThu1 = dt.Compute("sum([B1_TieuThu])", "[Loai]=1 or [Loai]=2 or [Loai]=4").ToString();
                string B2_TieuThu1 = dt.Compute("sum([B2_TieuThu])", "[Loai]=1 or [Loai]=2 or [Loai]=4").ToString();
                string B3_TieuThu1 = dt.Compute("sum([B3_TieuThu])", "[Loai]=1 or [Loai]=2 or [Loai]=4").ToString();
                // var Tong_TieuThu1 = dt.Rows[0]["Tong_TieuThu1"] + "";

                if (B1_TieuThu1 != "")
                {
                    B1 = decimal.Parse(B1_TieuThu1.Replace(".", ""));
                }
                if (B1_TieuThu1 != "")
                {
                    B2 = decimal.Parse(B2_TieuThu1.Replace(".", ""));
                }
                if (B1_TieuThu1 != "")
                {
                    B3 = decimal.Parse(B3_TieuThu1.Replace(".", ""));
                }
                decimal Tong = B1 + B2 + B3;
                if (Tong != 0)
                {
                    //decimal Tong = decimal.Parse(Tong_TieuThu1.Replace(".", ""));
                    decimal tlB1 = B1 * 100 / Tong;
                    tlB1 = Math.Round(tlB1, 2);
                    decimal tlB2 = B2 * 100 / Tong;
                    tlB2 = Math.Round(tlB2, 2);
                    decimal tlB3 = B3 * 100 / Tong;
                    tlB3 = Math.Round(tlB3, 2);
                    var B1_TieuThu   = string.Format("{0:N0} ", B1);
                    var B2_TieuThu   = string.Format("{0:N0} ", B2);
                    var B3_TieuThu   = string.Format("{0:N0} ", B3);
                    var Tong_TieuThu = string.Format("{0:N0} ", Tong);

                    dsdt.Rows.Add(j, Ten, B1_TieuThu, B2_TieuThu, B3_TieuThu, Tong_TieuThu, B1, B2, B3, Tong, tlB1, tlB2, tlB3);
                }
            }
            int a = dsdt.Rows.Count;

            if (a > 1)
            {
                MTCSYT.Report.InDienNhan3ThoiDiem report = new MTCSYT.Report.InDienNhan3ThoiDiem(dsdt, "" + cmbThang.Value, "" + cmbNam.Value, false, false, "", "", strGiao, strNhan, "", "", strGDNhan, strGDGiao);
                ReportViewer2.Report = report;

                ReportToolbar2.ReportViewer = ReportViewer2;
            }
        }
Esempio n. 3
0
        public InBieuTong(int chinhanh, int ma_dviqly, int thang, int nam, string userKyGiao, string userKyNhan, string tenDonvi, string DVGiao, string DVNhan, int loai, string strImTPNhan, string strImTPGiao, string strImGDNhan, string strImGDGiao)
        {
            InitializeComponent();
            if (chinhanh == 0)
            {
                return;
            }
            if (strImGDNhan != "")
            {
                rTNhan.Html = "<span align='center' style='color:red;font-weight:bold'> Đã ký: Người ký " + strImGDNhan + "</span>";
            }
            if (strImGDGiao != "")
            {
                rTGiao.Html = "<span align='center' style='color:red;font-weight:bold'>Đã ký: Người ký " + strImGDGiao + "</span>";
            }

            xlThangNam.Text = "Tháng " + DateTime.Now.Month + " Năm " + DateTime.Now.Year;
            // lbDLNhanKy.Text = DVNhan.ToUpper();
            lbDLNhanKy.Text = DVNhan;
            lbDLGiaoKy.Text = DVGiao;
            var cnList = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == chinhanh);
            var giao   = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cnList.DiemDauNguon);
            var nhan   = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cnList.DiemCuoiNguon);

            if (nhan.IDMA_DVIQLY != 2)
            {
                lbDonvi.Text = nhan.TEN_DVIQLY;
            }
            else
            {
                lbDonvi.Text = giao.TEN_DVIQLY;
            }
            if (cnList.DiemCuoiNguon == 2 || cnList.DiemDauNguon == 2)
            {
                if (ma_dviqly != 2)
                {
                    ma_dviqly = 2;
                }
            }

            if (loai == 0)
            {
                if (ma_dviqly != 2)
                {
                    var lst = db.db_GetSanLuongIDGiaoNhan(ma_dviqly, chinhanh, thang, nam);


                    foreach (var chitiet in lst)
                    {
                        string tendvBC = "";
                        if (!tenDonvi.Contains("TỔNG CÔNG TY ĐIỆN LỰC MIỀN BẮC"))
                        {
                            tendvBC = tenDonvi;
                        }
                        else if (!chitiet.dvGiao.Contains("TỔNG CÔNG TY ĐIỆN LỰC MIỀN BẮC"))
                        {
                            tendvBC = chitiet.dvGiao;
                        }
                        else if (!chitiet.dvNhan.Contains("TỔNG CÔNG TY ĐIỆN LỰC MIỀN BẮC"))
                        {
                            tendvBC = chitiet.dvNhan;
                        }
                        //lbDonvi.Text = tendvBC;
                        xlGhiChu1.Text = "Sản lượng điện năng giao nhận tháng " + thang + " năm " + nam + " giữa " + chitiet.dvGiao + " với " + chitiet.dvNhan + " như sau:";
                        xlGhiChu2.Text = "1. Tổng sản lượng " + chitiet.dvGiao + " Giao cho " + chitiet.dvNhan + " trong tháng:";
                        xlGhiChu3.Text = "2. Tổng sản lượng " + chitiet.dvGiao + " nhận từ " + chitiet.dvNhan + " trong tháng:";

                        xlBieu1G.Text      = string.Format("{0:N0} ", chitiet.Giao_Bieu1_SanLuong).Replace(",", ".");
                        xlBieu2G.Text      = string.Format("{0:N0} ", chitiet.Giao_Bieu2_SanLuong).Replace(",", ".");
                        xlBieu3G.Text      = string.Format("{0:N0} ", chitiet.Giao_Bieu3_SanLuong).Replace(",", ".");
                        xlTongSLuongG.Text = (chitiet.Giao_Bieu1_SanLuong + chitiet.Giao_Bieu2_SanLuong + chitiet.Giao_Bieu3_SanLuong).ToString().Replace(",", ".");

                        xlB1N.Text      = string.Format("{0:N0} ", chitiet.Nhan_Bieu1_SanLuong).Replace(",", ".");
                        xlB2N.Text      = string.Format("{0:N0} ", chitiet.Nhan_Bieu2_SanLuong).Replace(",", ".");
                        xlB3N.Text      = string.Format("{0:N0} ", chitiet.Nhan_Bieu3_SanLuong).Replace(",", ".");
                        xlTongSlgN.Text = (chitiet.Nhan_Bieu1_SanLuong + chitiet.Nhan_Bieu2_SanLuong + chitiet.Nhan_Bieu3_SanLuong).ToString().Replace(",", ".");

                        break;
                    }

                    var lst1Gia = db.db_GetSanLuongIDGiaoNhan_1Gia(ma_dviqly, chinhanh, thang, nam);

                    foreach (var chitiet in lst1Gia)
                    {
                        xlCongTo1G.Text = (chitiet.Giao_Bieu1_SanLuong + chitiet.Giao_Bieu2_SanLuong + chitiet.Giao_Bieu3_SanLuong).ToString().Replace(",", ".");
                        xlCto1N.Text    = (chitiet.Nhan_Bieu1_SanLuong + chitiet.Nhan_Bieu2_SanLuong + chitiet.Nhan_Bieu3_SanLuong).ToString().Replace(",", ".");

                        break;
                    }
                    //if (GiaoKy || NhanKy)
                    //{
                    //    xldaKyGiao.Text = "Đã ký";
                    //    xlDaKyNhan.Text = "Đã ký";
                    //}
                    xlTongSlgN.Text    = string.Format("{0:N0} ", (decimal.Parse(xlTongSlgN.Text) + decimal.Parse(xlCto1N.Text))).Replace(",", ".");
                    xlTongSLuongG.Text = string.Format("{0:N0} ", (decimal.Parse(xlTongSLuongG.Text) + decimal.Parse(xlCongTo1G.Text))).Replace(",", ".");
                }
                else
                {
                    DataTable dt = new DataTable();

                    CBDN.Class.InBienBanQT inBienBan = new CBDN.Class.InBienBanQT();
                    string strGiao = "", strNhan = "", strGDNhan = "", strGDGiao = "";

                    int donvi = ma_dviqly; int phuongthuc = chinhanh;
                    var checkphuongthuc = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == phuongthuc);
                    if (checkphuongthuc.DiemCuoiNguon == 2 || checkphuongthuc.DiemDauNguon == 2)
                    {
                        donvi      = int.Parse(db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(phuongthuc + "")).IDMADVIQLY.Replace(",2,", "").Replace(",", ""));
                        phuongthuc = 0;
                    }

                    var dvGiao = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == 2);
                    int dvi = 0;
                    if (checkphuongthuc.DiemCuoiNguon == 2)
                    {
                        dvi = checkphuongthuc.DiemDauNguon;
                    }
                    if (checkphuongthuc.DiemDauNguon == 2)
                    {
                        dvi = checkphuongthuc.DiemCuoiNguon;
                    }

                    var dvNhan = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == dvi);

                    xlGhiChu1.Text = "Sản lượng điện năng giao nhận tháng " + thang + " năm " + nam + " giữa " + dvGiao.TEN_DVIQLY + " với " + dvNhan.TEN_DVIQLY + " như sau:";
                    xlGhiChu2.Text = "1. Tổng sản lượng " + dvGiao.TEN_DVIQLY + " Giao cho " + dvNhan.TEN_DVIQLY + " trong tháng:";
                    xlGhiChu3.Text = "2. Tổng sản lượng " + dvGiao.TEN_DVIQLY + " nhận từ " + dvNhan.TEN_DVIQLY + " trong tháng:";


                    dt                 = inBienBan.InBienBanQuyetToan(phuongthuc, donvi, thang, nam, ref strGiao, ref strNhan, ref strGDNhan, ref strGDGiao);
                    xlBieu1G.Text      = string.Format("{0:N0} ", dt.Compute("sum(Nhan_Bieu1_SanLuong)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");
                    xlBieu2G.Text      = string.Format("{0:N0} ", dt.Compute("sum(Nhan_Bieu2_SanLuong)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");
                    xlBieu3G.Text      = string.Format("{0:N0} ", dt.Compute("sum(Nhan_Bieu3_SanLuong)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");
                    xlCongTo1G.Text    = string.Format("{0:N0} ", dt.Compute("sum(Nhan1Gia)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");
                    xlTongSLuongG.Text = string.Format("{0:N0} ", dt.Compute("sum(TongNhan3B)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");

                    xlB1N.Text      = string.Format("{0:N0} ", dt.Compute("sum(Giao_Bieu1_SanLuong)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");
                    xlB2N.Text      = string.Format("{0:N0} ", dt.Compute("sum(Giao_Bieu2_SanLuong)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");
                    xlB3N.Text      = string.Format("{0:N0} ", dt.Compute("sum(Giao_Bieu3_SanLuong)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");
                    xlCto1N.Text    = string.Format("{0:N0} ", dt.Compute("sum(Giao1Gia)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");
                    xlTongSlgN.Text = string.Format("{0:N0} ", dt.Compute("sum(TongGiao3B)", "Loai>0 and Loai<5 and Loai <> 3")).Replace(",", ".");
                }
            }
            else
            {
                var lst = db.db_CHOT_GetSanLuongIDGiaoNhan(ma_dviqly, chinhanh, thang, nam);
                foreach (var chitiet in lst)
                {
                    string tendvBC = "";
                    if (!tenDonvi.Contains("TỔNG CÔNG TY ĐIỆN LỰC MIỀN BẮC"))
                    {
                        tendvBC = tenDonvi;
                    }
                    else if (!chitiet.dvGiao.Contains("TỔNG CÔNG TY ĐIỆN LỰC MIỀN BẮC"))
                    {
                        tendvBC = chitiet.dvGiao;
                    }
                    else if (!chitiet.dvNhan.Contains("TỔNG CÔNG TY ĐIỆN LỰC MIỀN BẮC"))
                    {
                        tendvBC = chitiet.dvNhan;
                    }
                    //lbDonvi.Text = tendvBC;
                    xlGhiChu1.Text = "Sản lượng điện năng giao nhận tháng " + thang + " năm " + nam + " giữa " + chitiet.dvGiao + " với " + chitiet.dvNhan + " như sau:";
                    xlGhiChu2.Text = "1. Tổng sản lượng " + chitiet.dvGiao + " Giao cho " + chitiet.dvNhan + " trong tháng:";
                    xlGhiChu3.Text = "2. Tổng sản lượng " + chitiet.dvGiao + " nhận từ " + chitiet.dvNhan + " trong tháng:";

                    xlBieu1G.Text      = string.Format("{0:N0} ", chitiet.Giao_Bieu1_SanLuong).Replace(",", ".");
                    xlBieu2G.Text      = string.Format("{0:N0} ", chitiet.Giao_Bieu2_SanLuong).Replace(",", ".");
                    xlBieu3G.Text      = string.Format("{0:N0} ", chitiet.Giao_Bieu3_SanLuong).Replace(",", ".");
                    xlTongSLuongG.Text = (chitiet.Giao_Bieu1_SanLuong + chitiet.Giao_Bieu2_SanLuong + chitiet.Giao_Bieu3_SanLuong).ToString().Replace(",", ".");

                    xlB1N.Text      = string.Format("{0:N0} ", chitiet.Nhan_Bieu1_SanLuong).Replace(",", ".");
                    xlB2N.Text      = string.Format("{0:N0} ", chitiet.Nhan_Bieu2_SanLuong).Replace(",", ".");
                    xlB3N.Text      = string.Format("{0:N0} ", chitiet.Nhan_Bieu3_SanLuong).Replace(",", ".");
                    xlTongSlgN.Text = (chitiet.Nhan_Bieu1_SanLuong + chitiet.Nhan_Bieu2_SanLuong + chitiet.Nhan_Bieu3_SanLuong).ToString().Replace(",", ".");

                    break;
                }
                var lst1Gia = db.db_GetSanLuongIDGiaoNhan_1Gia(ma_dviqly, chinhanh, thang, nam);

                foreach (var chitiet in lst1Gia)
                {
                    xlCongTo1G.Text = (chitiet.Giao_Bieu1_SanLuong + chitiet.Giao_Bieu2_SanLuong + chitiet.Giao_Bieu3_SanLuong).ToString().Replace(",", ".");
                    xlCto1N.Text    = (chitiet.Nhan_Bieu1_SanLuong + chitiet.Nhan_Bieu2_SanLuong + chitiet.Nhan_Bieu3_SanLuong).ToString().Replace(",", ".");

                    break;
                }
                //if (GiaoKy || NhanKy)
                //{
                //    xldaKyGiao.Text = "Đã ký";
                //    xlDaKyNhan.Text = "Đã ký";
                //}
                xlTongSlgN.Text    = string.Format("{0:N0} ", (decimal.Parse(xlTongSlgN.Text) + decimal.Parse(xlCto1N.Text))).Replace(",", ".");
                xlTongSLuongG.Text = string.Format("{0:N0} ", (decimal.Parse(xlTongSLuongG.Text) + decimal.Parse(xlCongTo1G.Text))).Replace(",", ".");
            }
        }