Beispiel #1
0
        private void setControlText(int idCongTo)
        {
            var congto = db.DM_CongTos.SingleOrDefault(x => x.IDCongTo == idCongTo);

            if (congto != null)
            {
                lbMaCT.Text      = congto.MaCongTo;
                lbTenCongTo.Text = congto.TenCongTo;
                lbChungLoai.Text = congto.ChungLoai;
                lbCDA.Text       = congto.CapDienAp + "";
                lbIDCongTO.Text  = idCongTo + "";
                lbDiemDo.Text    = db.DM_DiemDos.SingleOrDefault(x => x.IDDiemDo == congto.IDDiemDo).TenDiemDo;
                lbDVGiao.Text    = dm_dviSer.SelectDM_DVQLY((int)congto.IDDonViGiao).NAME_DVIQLY;
                lbDVNhan.Text    = dm_dviSer.SelectDM_DVQLY((int)congto.IDDonViNhan).NAME_DVIQLY;
                lbHangSX.Text    = congto.HangSanXuat;
                lbHSNhan.Text    = congto.HeSoNhan + "";
                lbHSQuyDoi.Text  = congto.HeSoQuyDoi + "";
                lbKenhNhan.Text  = congto.KenhGiaoCongTo;
                lbKenhNhan.Text  = congto.KenhNhanCongTo;
                lbMoTa.Text      = congto.MoTa;

                lbNgayHieuLuc.Text = congto.NgayTreoThao + "";
                lbNgaySua.Text     = congto.NgayTao + "";
                lbngayTao.Text     = congto.NgayTao + "";
                lbPhuongthuc.Text  = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == congto.IDChiNhanh).TenChiNhanh;
            }
        }
Beispiel #2
0
        protected void cmbCuoiNguon_SelectedIndexChanged(object sender, EventArgs e)
        {
            SYS_Session     session   = (SYS_Session)Session["SYS_Session"];
            DM_DVQLYService dm_dviSer = new DM_DVQLYService();
            var             dvDN      = dm_dviSer.SelectDM_DVQLY(int.Parse(session.User.ma_dviqly));
            var             dvChon    = dm_dviSer.SelectDM_DVQLY(int.Parse(cmbCuoiNguon.Value + ""));

            txtMaDuongDat.Text = dvDN.MA_DVIQLY + "_" + dvChon.MA_DVIQLY;
        }
Beispiel #3
0
        private void InTongHopDienNang()
        {
            if (cmbPhuongThuc.Value == null)
            {
                return;
            }

            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(ma_dviqly);

            //  if (Request["XacNhan"] + "" == "1") kiemtra = true;
            string strGiao, strNhan; string strGDNhan = "", strGDGiao = "";

            if (cmbPhuongThuc.Value + "" != "0")
            {
                var           cn = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(cmbPhuongThuc.Value + ""));
                CBDN.DM_DVQLY giao, nhan;
                if (cn.IDMADVIQLY.Contains(",2,"))
                {
                    giao = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == 2);
                    nhan = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == int.Parse(cn.IDMADVIQLY.Replace(",2,", "").Replace(",", "")));
                }
                else
                {
                    giao = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cn.DiemDauNguon);
                    nhan = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cn.DiemCuoiNguon);
                }
                strGiao = giao.TEN_DVIQLY;
                strNhan = nhan.TEN_DVIQLY;


                var imGDGiao = db.HD_ThongTinKies.SingleOrDefault(x => x.IDMaDViQLy == cn.DiemDauNguon && x.IDChinhNhanh == int.Parse(cmbPhuongThuc.Value + "") && x.Thang == int.Parse(cmbThang.Value + "") && x.Nam == int.Parse(cmbNam.Value + "") && x.ChucVu == 3);
                var imGDNhan = db.HD_ThongTinKies.SingleOrDefault(x => x.IDMaDViQLy == cn.DiemCuoiNguon && x.IDChinhNhanh == int.Parse(cmbPhuongThuc.Value + "") && x.Thang == int.Parse(cmbThang.Value + "") && x.Nam == int.Parse(cmbNam.Value + "") && x.ChucVu == 3);

                if (imGDGiao != null)
                {
                    var ngGiao = db.DM_USERs.SingleOrDefault(x => x.IDUSER == imGDGiao.NguoiTao);
                    strGDGiao = ngGiao.HOTEN + "</br> Thời gian xác nhận: " + imGDGiao.NgayTao;
                }
                if (imGDNhan != null)
                {
                    var ngNhan = db.DM_USERs.SingleOrDefault(x => x.IDUSER == imGDNhan.NguoiTao);
                    strGDNhan = ngNhan.HOTEN + "</br> Thời gian xác nhận: " + imGDNhan.NgayTao;
                }
            }
            else
            {
                strGiao = "TỔNG CÔNG TY ĐIỆN LỰC MIỀM BẮC";
                strNhan = donvi.TEN_DVIQLY;
            }


            MTCSYT.Report.InBieuTong report = new MTCSYT.Report.InBieuTong(int.Parse(cmbPhuongThuc.Value + ""), ma_dviqly, int.Parse(cmbThang.Value + ""), int.Parse(cmbNam.Value + ""), "", "", donvi.TEN_DVIQLY, strGiao, strNhan, 0, "", "", strGDNhan, strGDGiao);

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #4
0
        private void InTongHopKHDAThap()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(ma_dviqly);
            var             lst        = db.TT_KhachHangDAThapTrongThang(int.Parse(session.User.ma_dviqly + ""), int.Parse("" + Request["Thang"]), int.Parse("" + Request["Nam"])).ToList();
            DataTable       dt         = new DataTable();

            dt.Columns.Add("STT");
            dt.Columns.Add("TenDonVi");
            dt.Columns.Add("SOKH");
            dt.Columns.Add("KH160", typeof(decimal));
            dt.Columns.Add("KH180", typeof(decimal));
            dt.Columns.Add("KH200", typeof(decimal));
            dt.Columns.Add("GiaiPhap");
            dt.Columns.Add("TienDo");

            int stt = 1;

            foreach (var chitiet in lst)
            {
                dt.Rows.Add(stt, chitiet.TEN_DVIQLY, chitiet.SoTBA, chitiet.KH160, chitiet.KH180, chitiet.KH200, chitiet.GiaiPhap, chitiet.TienDoThucHien);
                stt++;
            }

            MTCSYT.Report.KHDAThap report = new MTCSYT.Report.KHDAThap(dt, "" + Request["Thang"], "" + Request["Nam"], donvi.TEN_DVIQLY);

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #5
0
        private void loadDanhMuc()
        {
            DM_DVQLYService dm_dviSer = new DM_DVQLYService();
            DataTable       lst_dmdv  = new DataTable();

            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int ma_dviqly = int.Parse(session.User.ma_dviqly + "");
            var donvi     = dm_dviSer.SelectDM_DVQLY(ma_dviqly);

            if (donvi.ParentId == 0 || donvi.ParentId == 61)
            {
                lst_dmdv = dm_dviSer.SelectAll_DVI_ByChild(ma_dviqly);
                cmbMaDonVi.DataSource = lst_dmdv;
                cmbMaDonVi.ValueField = "IDMA_DVIQLY";
                cmbMaDonVi.TextField  = "NAME_DVIQLY";
                cmbMaDonVi.DataBind();
            }
            else
            {
                List <Entity.DM_DVQLY> lst = new List <DM_DVQLY>();
                lst.Add(donvi);
                cmbMaDonVi.DataSource = lst;
                cmbMaDonVi.ValueField = "IDMA_DVIQLY";
                cmbMaDonVi.TextField  = "NAME_DVIQLY";
                cmbMaDonVi.DataBind();
            }
        }
Beispiel #6
0
        private void LoadDataDV()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int a = int.Parse(session.User.ma_dviqly + "");

            if (MaDienLuc.Value + "" != "")
            {
                if (a > 38)
                {
                    DM_DVQLYService dm_dviSer = new DM_DVQLYService();
                    var             donvi     = dm_dviSer.SelectDM_DVQLY(a);
                    List <DM_DS>    List      = new List <DM_DS>();
                    DM_DS           Dvi       = new DM_DS();

                    Dvi.MA_DVIQLY   = session.User.ma_dviqlyDN + "";
                    Dvi.NAME_DVIQLY = donvi.NAME_DVIQLY.Split('-')[1].ToString().ToUpper();
                    List.Add(Dvi);

                    cmMaDvi.DataSource = List;
                    cmMaDvi.TextField  = "NAME_DVIQLY";
                    cmMaDvi.ValueField = "MA_DVIQLY";
                    cmMaDvi.DataBind();
                }
                else
                {
                    DM_DVQLYService dm_dviSer = new DM_DVQLYService();
                    //  DataTable lst_dmdv = new DataTable();
                    var lst_dmdv = dm_dviSer.SelectAll_DVI_ByChild(int.Parse(MaDienLuc.Value + ""));
                    cmMaDvi.DataSource = lst_dmdv;
                    cmMaDvi.ValueField = "MA_DVIQLY";
                    cmMaDvi.TextField  = "NAME_DVIQLY";
                    cmMaDvi.DataBind();
                }
            }
        }
Beispiel #7
0
        private void InTongHopDienNang()
        {
            if (cmbPhuongThuc.Value == null || cmbPhuongThuc.Value + "" == "0")
            {
                return;
            }

            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(ma_dviqly);

            //  if (Request["XacNhan"] + "" == "1") kiemtra = true;

            var cn = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(cmbPhuongThuc.Value + ""));

            CBDN.DM_DVQLY giao, nhan;
            if (cn.IDMADVIQLY.Contains(",2,"))
            {
                giao = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == 2);
                nhan = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == int.Parse(cn.IDMADVIQLY.Replace(",2,", "").Replace(",", "")));
            }
            else
            {
                giao = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cn.DiemDauNguon);
                nhan = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cn.DiemCuoiNguon);
            }

            MTCSYT.Report.InBieuTong report = new MTCSYT.Report.InBieuTong(int.Parse(cmbPhuongThuc.Value + ""), ma_dviqly, int.Parse(cmbThang.Value + ""), int.Parse(cmbNam.Value + ""), "", "", donvi.TEN_DVIQLY, giao.TEN_DVIQLY, nhan.TEN_DVIQLY, 0, "", "", "", "");

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #8
0
        protected void cmbDiemDo_SelectedIndexChanged(object sender, EventArgs e)
        {
            var lstDD = db.DM_DiemDos.SingleOrDefault(x => x.IDDiemDo == int.Parse(cmbDiemDo.Value + ""));


            List <Entity.DM_DVQLY> lst = new List <DM_DVQLY>();
            var chinhanh = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == lstDD.IDChiNhanh);
            var DonVi    = dm_dviSer.SelectDM_DVQLY(chinhanh.DiemDauNguon);

            lst.Add(DonVi);

            if (chinhanh.DiemDauNguon != chinhanh.DiemCuoiNguon)
            {
                var DonVi2 = dm_dviSer.SelectDM_DVQLY(chinhanh.DiemCuoiNguon);
                lst.Add(DonVi2);
            }
        }
Beispiel #9
0
        private void InTongHopDienNang()
        {
            if (cmbPhuongThuc.Value == null || cmbPhuongThuc.Value + "" == "0")
            {
                return;
            }
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(ma_dviqly);

            var cn = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(cmbPhuongThuc.Value + ""));

            CBDN.DM_DVQLY giao, nhan;
            if (cn.IDMADVIQLY.Contains(",2,"))
            {
                giao = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == 2);
                nhan = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == int.Parse(cn.IDMADVIQLY.Replace(",2,", "").Replace(",", "")));
            }
            else
            {
                giao = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cn.DiemDauNguon);
                nhan = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cn.DiemCuoiNguon);
            }
            string strTPGiao = "", strTPNhan = "", strGDNhan = "", strGDGiao = "";
            var    lstHDKy = db.HD_ThongTinKies.Where(x => x.IDChinhNhanh == int.Parse(cmbPhuongThuc.Value + "") && x.Thang == int.Parse(cmbThang.Value + "") && x.Nam == int.Parse(cmbNam.Value + ""));

            foreach (var hdKy in lstHDKy)
            {
                if (hdKy.ChucVu == 2 && hdKy.IDMaDViQLy == giao.IDMA_DVIQLY)
                {
                    strTPGiao = hdKy.Link;
                }
                if (hdKy.ChucVu == 2 && hdKy.IDMaDViQLy == nhan.IDMA_DVIQLY)
                {
                    strTPNhan = hdKy.Link;
                }
                if (hdKy.ChucVu == 3 && hdKy.IDMaDViQLy == giao.IDMA_DVIQLY)
                {
                    strGDGiao = hdKy.Link;
                }
                if (hdKy.ChucVu == 3 && hdKy.IDMaDViQLy == nhan.IDMA_DVIQLY)
                {
                    strGDNhan = hdKy.Link;
                }
            }


            MTCSYT.Report.InBieuTong report = new MTCSYT.Report.InBieuTong(int.Parse(cmbPhuongThuc.Value + ""), ma_dviqly, int.Parse(cmbThang.Value + ""), int.Parse(cmbNam.Value + ""), "", "", donvi.TEN_DVIQLY, giao.TEN_DVIQLY, nhan.TEN_DVIQLY, 0, strTPNhan, strTPGiao, "", "");

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #10
0
        private void dZ()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(ma_dviqly);
            DataTable       dt         = dbOR.Get_BCTT_LDD(Request["DonVi"] + "", int.Parse("" + Request["Thang"]), int.Parse("" + Request["Nam"]), Request["LanBC"] + "", int.Parse(Request["LuyKe"] + ""));

            MTCSYT.Report.InTrungAp report = new MTCSYT.Report.InTrungAp(dt, "" + Request["Thang"], "" + Request["Nam"], donvi.TEN_DVIQLY);

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #11
0
        private void DN_TK_ChiTietThuongPham()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(int.Parse(Request["DonVi"] + ""));
            DataTable       dt         = Dienthuongpham();

            MTCSYT.Report.InDN_ThuongPham report = new MTCSYT.Report.InDN_ThuongPham(dt, "" + Request["Thang"], "" + Request["Nam"], donvi.TEN_DVIQLY, int.Parse(Request["DonVi"] + ""));

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #12
0
        protected void btnHuyNhan_Click(object sender, EventArgs e)
        {
            SYS_Session session     = (SYS_Session)Session["SYS_Session"];
            string      strMadviqly = session.User.ma_dviqly;

            DM_DVQLYService isyOrganizationService = new DM_DVQLYService();

            Entity.DM_DVQLY sysOrganization = new Entity.DM_DVQLY();

            sysOrganization = isyOrganizationService.SelectDM_DVQLY(int.Parse(strMadviqly));

            if (rdImportDuLieu.SelectedIndex == 0)
            {
            }
            else
            {
                var lstData = dbSQL.CMIS_DDoGCs.Where(x => x.MA_DVIQLY == sysOrganization.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + ""));

                string tenfile = "";
                foreach (var a in lstData)
                {
                    tenfile = a.TENFILE;
                    break;
                }
                Class.XuatXML_GCS       class_xuatso = new Class.XuatXML_GCS();
                DataSet                 ds           = new DataSet();
                CBDN.ConvertListToTable cv           = new CBDN.ConvertListToTable();
                DataTable               dt           = cv.ConvertToDataTable(lstData.ToList());
                dt.Columns.Remove("TENFILE");
                dt.Columns.Remove("TrangThaiDongBo");
                ds.Tables.Add(dt);
                string strXML  = class_xuatso.HTML_XuatFileCMIS();
                string strXML1 = ds.GetXml();
                //strXML1 = strXML1.Replace(",", ".");
                strXML1 = strXML1.Replace("<NewDataSet>", "");
                strXML1 = strXML1.Replace("</NewDataSet>", "");
                strXML1 = strXML1.Replace("<Table>", "<Table1>");
                strXML1 = strXML1.Replace("</Table>", "</Table1>");
                strXML += strXML1 + "</NewDataSet>";

                string attachment = "attachment;filename=" + tenfile + ".XML";
                Response.ClearContent();
                Response.ContentType = "application/xml";
                Response.AddHeader("content-disposition", attachment);
                Response.Write(strXML);

                Response.End();
            }
        }
Beispiel #13
0
        private void loadDLDongBo()
        {
            SYS_Session session     = (SYS_Session)Session["SYS_Session"];
            string      strMadviqly = session.User.ma_dviqly;

            DM_DVQLYService isyOrganizationService = new DM_DVQLYService();

            Entity.DM_DVQLY sysOrganization = new Entity.DM_DVQLY();

            sysOrganization = isyOrganizationService.SelectDM_DVQLY(int.Parse(strMadviqly));
            var lst = dbSQL.CMIS_DDoGCs.Where(x => x.MA_DVIQLY == sysOrganization.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + "") && x.TrangThaiDongBo == 1);

            grdCN.DataSource = lst;
            grdCN.DataBind();
        }
        private void InTongHopDienNang()
        {
            if (cmbPhuongThuc.Value == null || cmbPhuongThuc.Value + "" == "")
            {
                return;
            }

            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(ma_dviqly);

            //  if (Request["XacNhan"] + "" == "1") kiemtra = true;

            var cn   = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(cmbPhuongThuc.Value + ""));
            var giao = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cn.DiemDauNguon);
            var nhan = db.DM_DVQLies.SingleOrDefault(x => x.IDMA_DVIQLY == cn.DiemCuoiNguon);

            string strTPGiao = "", strTPNhan = "", strGDNhan = "", strGDGiao = "";
            //var imTPGiao = db.HD_ThongTinKies.SingleOrDefault(x => x.IDMaDViQLy == cn.DiemDauNguon && x.IDChinhNhanh==int.Parse(cmbPhuongThuc.Value+"") && x.Thang == int.Parse(cmbThang.Value + "") && x.Nam == int.Parse(cmbNam.Value + "") && x.ChucVu == 2);
            //var imTPNhan = db.HD_ThongTinKies.SingleOrDefault(x => x.IDMaDViQLy == cn.DiemCuoiNguon && x.IDChinhNhanh == int.Parse(cmbPhuongThuc.Value + "") && x.Thang == int.Parse(cmbThang.Value + "") && x.Nam == int.Parse(cmbNam.Value + "") && x.ChucVu == 2);

            var imGDGiao = db.HD_ThongTinKies.SingleOrDefault(x => x.IDMaDViQLy == cn.DiemDauNguon && x.IDChinhNhanh == int.Parse(cmbPhuongThuc.Value + "") && x.Thang == int.Parse(cmbThang.Value + "") && x.Nam == int.Parse(cmbNam.Value + "") && x.ChucVu == 3 && x.TrangThai == null);
            var imGDNhan = db.HD_ThongTinKies.SingleOrDefault(x => x.IDMaDViQLy == cn.DiemCuoiNguon && x.IDChinhNhanh == int.Parse(cmbPhuongThuc.Value + "") && x.Thang == int.Parse(cmbThang.Value + "") && x.Nam == int.Parse(cmbNam.Value + "") && x.ChucVu == 3 && x.TrangThai == null);

            //if (imTPGiao != null)
            //    strTPGiao = imTPGiao.Link;
            //if (imTPNhan != null)
            //    strTPNhan = imTPNhan.Link;
            if (imGDGiao != null)
            {
                var ngGiao = db.DM_USERs.SingleOrDefault(x => x.IDUSER == imGDGiao.NguoiTao);
                strGDGiao = ngGiao.HOTEN + "</br> Thời gian xác nhận: " + imGDGiao.NgayTao;
            }
            if (imGDNhan != null)
            {
                var ngNhan = db.DM_USERs.SingleOrDefault(x => x.IDUSER == imGDNhan.NguoiTao);
                strGDNhan = ngNhan.HOTEN + "</br> Thời gian xác nhận: " + imGDNhan.NgayTao;
            }

            MTCSYT.Report.InBieuTong report = new MTCSYT.Report.InBieuTong(int.Parse(cmbPhuongThuc.Value + ""), ma_dviqly, int.Parse(cmbThang.Value + ""), int.Parse(cmbNam.Value + ""), "", "", donvi.TEN_DVIQLY, giao.TEN_DVIQLY, nhan.TEN_DVIQLY, 0, strTPNhan, strTPGiao, strGDNhan, strGDGiao);

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #15
0
        //private void loadDanhMuc()
        //{
        //    MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
        //    int ma_dviqly = int.Parse(session.User.ma_dviqly + "");

        //    tlDonVi.DataSource = db.db_ChiNhanhSelectXacNhan(ma_dviqly, int.Parse(cmbThang.Value + ""), int.Parse(cmbNam.Value + "")).ToList();
        //    tlDonVi.DataBind();
        //}
        private void InTongHopDienNang()
        {
            if (cmbPhuongThuc.Value != null)
            {
                MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
                int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
                DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
                var             donvi      = dm_dviSer.SelectDM_DVQLY(ma_dviqly);
                bool            kiemtra    = false;
                //  if (Request["XacNhan"] + "" == "1") kiemtra = true;

                //MTCSYT.Report.InBieuTong report = new MTCSYT.Report.InBieuTong(int.Parse(cmbPhuongThuc.Value + ""), ma_dviqly, int.Parse(cmbThang.Value + ""), int.Parse(cmbNam.Value + ""), kiemtra, kiemtra, "", "", donvi.TEN_DVIQLY, 0,"","","","");

                //ReportViewer1.Report = report;

                //ReportToolbar1.ReportViewer = ReportViewer1;
            }
        }
Beispiel #16
0
        private void laodDVCapCha()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int a = int.Parse(session.User.ma_dviqly + "");

            if (a == 2)
            {
                DM_DVQLYService dm_dviSer = new DM_DVQLYService();

                var lst_dmdv = dm_dviSer.SelectAllDM_DVQLY();

                MaDienLuc.DataSource = lst_dmdv;
                MaDienLuc.ValueField = "IDMA_DVIQLY";
                MaDienLuc.TextField  = "TEN_DVIQLY";
                MaDienLuc.DataBind();
            }
            else if (a < 38)
            {
                DM_DVQLYService dm_dviSer = new DM_DVQLYService();
                var             donvi     = dm_dviSer.SelectDM_DVQLY(int.Parse(session.User.ma_dviqly));
                List <DM_DS>    List      = new List <DM_DS>();
                DM_DS           Dvi       = new DM_DS();

                Dvi.MA_DVIQLY   = donvi.IDMA_DVIQLY + "";
                Dvi.NAME_DVIQLY = donvi.NAME_DVIQLY.Split('-')[1].ToString().ToUpper();;
                List.Add(Dvi);

                MaDienLuc.DataSource = List;
                MaDienLuc.TextField  = "NAME_DVIQLY";
                MaDienLuc.ValueField = "MA_DVIQLY";
                MaDienLuc.DataBind();
            }
            else
            {
                DM_DVQLYService dm_dviSer = new DM_DVQLYService();

                var lst_dmdv = dm_dviSer.Select_DVI_Cha_ByChild(a);

                MaDienLuc.DataSource = lst_dmdv;
                MaDienLuc.ValueField = "IDMA_DVIQLY";
                MaDienLuc.TextField  = "TEN_DVIQLY";
                MaDienLuc.DataBind();
            }
        }
Beispiel #17
0
        private void DN_TK_ThuongPham_New()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(int.Parse(Request["DonVi"] + ""));


            int thangtr, namtr, thangN2, namN2;

            if (Request["Thang"] + "" == "1")
            {
                thangtr = 12;
                namtr   = int.Parse(Request["Nam"] + "") - 1;
                thangN2 = 11;
                namN2   = int.Parse(Request["Nam"] + "") - 1;
            }
            else if (Request["Thang"] + "" == "2")
            {
                thangtr = 1;
                namtr   = int.Parse(Request["Nam"] + "");
                thangN2 = 12;
                namN2   = int.Parse(Request["Nam"] + "") - 1;
            }
            else
            {
                thangtr = int.Parse(Request["Thang"] + "") - 1;
                namtr   = int.Parse(Request["Nam"] + "");
                thangN2 = int.Parse(Request["Thang"] + "") - 2;
                namN2   = int.Parse(Request["Nam"] + "");
            }

            //DataTable dt = dbOR.DN_TK_ThucTeTCT(int.Parse(Request["Thang"] + ""), int.Parse(Request["Nam"] + ""), thangtr, namtr, thangN2, namN2, int.Parse(Request["TuNgay"] + ""), int.Parse(Request["DenNgay"] + ""));

            CBDN.ConvertListToTable cv = new CBDN.ConvertListToTable();
            var       tk = db.DN_TK_ThucTeTCT(int.Parse(Request["Thang"] + ""), int.Parse(Request["Nam"] + ""), thangtr, namtr, thangN2, namN2, int.Parse(Request["TuNgay"] + ""), int.Parse(Request["DenNgay"] + ""));
            DataTable dt = cv.ConvertToDataTable(tk.ToList());

            MTCSYT.Report.InDN_ThuongPhamTCT report = new MTCSYT.Report.InDN_ThuongPhamTCT(dt, "" + Request["Thang"], "" + Request["Nam"], donvi.TEN_DVIQLY, int.Parse(Request["DonVi"] + ""));

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #18
0
        private void InTongHopDienNangSauChot()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(ma_dviqly);
            bool            kiemtra    = false;

            if (Request["XacNhan"] + "" == "1")
            {
                kiemtra = true;
            }

            //MTCSYT.Report.InBieuTong report = new MTCSYT.Report.InBieuTong(int.Parse(Request["ChinhNhanh"] + ""), ma_dviqly, int.Parse("" + Request["Thang"]), int.Parse("" + Request["Nam"]), kiemtra, kiemtra, "", "", donvi.TEN_DVIQLY, 1, "", "", "", "");

            //ReportViewer1.Report = report;

            //ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #19
0
        private void DN_TK_ChiTiet()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(int.Parse(Request["DonVi"] + ""));

            //CBDN.ConvertListToTable cv = new CBDN.ConvertListToTable();
            // var tk = db.DN_TK_ThucTeDonVi(int.Parse(Request["DonVi"] + ""), int.Parse("" + Request["Thang"]), int.Parse("" + Request["Nam"]));
            //DataTable dt = cv.ConvertToDataTable(tk.ToList());

            DataTable dt = dbOR.DN_TK_ThucTeDonVi_ByThangNam(int.Parse(Request["DonVi"] + ""), int.Parse("" + Request["Thang"]), int.Parse("" + Request["Nam"]));

            MTCSYT.Report.InDN_ChiTiet report = new MTCSYT.Report.InDN_ChiTiet(dt, "" + Request["Thang"], "" + Request["Nam"], donvi.TEN_DVIQLY, int.Parse(Request["DonVi"] + ""));

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #20
0
        private void DN_TK_KeHoach()
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int             ma_dviqly  = int.Parse(session.User.ma_dviqly);
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            var             donvi      = dm_dviSer.SelectDM_DVQLY(ma_dviqly);

            //DataTable dt = dbOR.DN_TK_DNKeHoach(int.Parse(session.User.ma_dviqly), int.Parse("" + Request["Thang"]), int.Parse("" + Request["Nam"]), int.Parse(Request["Ngay"] + ""));

            CBDN.ConvertListToTable cv = new CBDN.ConvertListToTable();
            var       tk = db.DN_TK_DNKeHoach(int.Parse(session.User.ma_dviqly), int.Parse("" + Request["Thang"]), int.Parse("" + Request["Nam"]), int.Parse(Request["Ngay"] + ""));
            DataTable dt = cv.ConvertToDataTable(tk.ToList());

            MTCSYT.Report.InDN_DuKien report = new MTCSYT.Report.InDN_DuKien(dt, "" + Request["Thang"], "" + Request["Nam"], Request["Ngay"], donvi.TEN_DVIQLY);

            ReportViewer1.Report = report;

            ReportToolbar1.ReportViewer = ReportViewer1;
        }
Beispiel #21
0
        private void LoadData()
        {
            DM_DVQLYService isyOrganizationService = new DM_DVQLYService();

            Entity.DM_DVQLY sysOrganization = new Entity.DM_DVQLY();

            if (TreeListOrganization.FocusedNode != null)
            {
                var parentNode = TreeListOrganization.FocusedNode;
                //cmbChoseParent.SelectedIndex = IndexOfTreelist(parentNode.ParentNode.Key);
                int IDOrganization = int.Parse(TreeListOrganization.FocusedNode.Key.ToString());

                sysOrganization          = isyOrganizationService.SelectDM_DVQLY(int.Parse(TreeListOrganization.FocusedNode.Key));
                txtNameOrganization.Text = sysOrganization.MA_DVIQLY;
                txtTenDV.Text            = sysOrganization.TEN_DVIQLY;
                txtTenVietTat.Text       = sysOrganization.TenVietTat;

                LoadCMBChooseParent(sysOrganization.ParentId);
                //cmbChoseParent.Value = sysOrganization.ParentId;
                Session["Organization"] = sysOrganization;
            }
        }
Beispiel #22
0
        protected void btnXuat_Click(object sender, EventArgs e)
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int ma_dviqly = int.Parse(session.User.ma_dviqly + "");
            var lst       = db.BC_KhuVuc_ChiTiet(ma_dviqly, int.Parse("0" + cmbThang.Value), int.Parse("0" + cmbNam.Value)).ToList();

            #region Chuẩn bị tệp excel mẫu để ghi dữ liệu
            string   destFile  = Server.MapPath("~/Tem/BC_KhuVuc.xls");
            string   sTemplate = (destFile);
            Workbook exBook    = new Workbook();
            exBook.Open(sTemplate, FileFormatType.Excel2003);
            _exSheet = exBook.Worksheets[0];
            _range   = _exSheet.Cells;
            #endregion

            // Xử lý replace các thông tin báo cáo tĩnh theo công ty
            //Report.ReplaceSpecificationField(_exSheet);

            int donghientai = 8;

            #region Ghi dữ liệu
            _exSheet.Replace("NGAYTHANG", "Ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year);
            DM_DVQLYService dm_dviSer = new DM_DVQLYService();
            var             donvi     = dm_dviSer.SelectDM_DVQLY(ma_dviqly);
            string          tongdong  = Session["tongdong"] + "";
            if (donvi.Type < 3)
            {
                _exSheet.Replace("ntTieuDe", "BÁO CÁO SẢN LƯỢNG ĐIỆN NĂNG GIAO NHẬN VỚI CÁC CÔNG TY ĐIỆN LỰC");
            }
            else
            {
                _exSheet.Replace("ntTieuDe", " BÁO CÁO ĐIỆN NĂNG GIAO NHẬN VỚI CÔNG TY " + donvi.TEN_DVIQLY);
            }
            if (lst.Count > 1)
            {
                _exSheet.Cells.InsertRows(donghientai + 1, (lst.Count() + int.Parse(tongdong)) * 5 - 3);
            }
            string macto = "", tenkhuvuc = "";
            int    vitri      = 0;
            Style  celicaStil = exBook.Styles[exBook.Styles.Add()];
            celicaStil.VerticalAlignment   = TextAlignmentType.Center;
            celicaStil.HorizontalAlignment = TextAlignmentType.Center;
            celicaStil.Pattern             = BackgroundType.Solid;
            celicaStil.Font.IsBold         = true;
            celicaStil.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
            StyleFlag                   flg = new StyleFlag();
            flg.Font        = true; int tongtram = 0;
            flg.CellShading = true;

            foreach (var ct in lst)
            {
                tongtram = tongtram + 1;
                celicaStil.VerticalAlignment = TextAlignmentType.Center;
                if (tenkhuvuc != ct.TEN_DVIQLY)
                {
                    var countKV = lst.Where(x => x.TEN_DVIQLY == ct.TEN_DVIQLY).Count();
                    _range[donghientai + vitri, 0].PutValue(ct.TEN_DVIQLY);
                    var categoryCounts =
                        from p in lst
                        group p by p.TenTram into g
                        select new { TEN_DVIQLY = ct.TEN_DVIQLY, ProductCount = g.Count() };

                    _range.Merge(donghientai + vitri, 0, (categoryCounts.Count() + int.Parse(tongdong)) * 5, 1);
                    _range[donghientai + vitri, 0].SetStyle(celicaStil);

                    tenkhuvuc = ct.TEN_DVIQLY;
                }

                if (macto != ct.MaCongTo)
                {
                    _range[donghientai + vitri, 1].PutValue(ct.TenTram);
                    _range.Merge(donghientai + vitri, 1, 5, 1);
                    _range[donghientai + vitri, 1].SetStyle(celicaStil);

                    _range[donghientai + vitri, 2].PutValue(ct.TenDiemDo);
                    _range.Merge(donghientai + vitri, 2, 5, 1);
                    _range[donghientai + vitri, 2].SetStyle(celicaStil);

                    _range[donghientai + vitri, 3].PutValue(ct.TU_TI);
                    _range.Merge(donghientai + vitri, 3, 5, 1);
                    _range[donghientai + vitri, 3].SetStyle(celicaStil);

                    _range[donghientai + vitri, 4].PutValue(ct.TenCongTo);
                    _range.Merge(donghientai + vitri, 4, 5, 1);
                    _range[donghientai + vitri, 4].SetStyle(celicaStil);

                    _range[donghientai + vitri, 5].PutValue(ct.HeSoNhan);
                    _range.Merge(donghientai + vitri, 5, 5, 1);
                    _range[donghientai + vitri, 5].SetStyle(celicaStil);

                    macto = ct.MaCongTo;
                }
                for (int i = 0; i < 5; i++)
                {
                    if (i == 0)
                    {
                        _range[donghientai + vitri + i, 6].PutValue("Tổng P");
                        _range[donghientai + vitri + i, 7].PutValue(ct.Giao_P_Dau);
                        _range[donghientai + vitri + i, 8].PutValue(ct.Giao_P_Cuoi);
                        _range[donghientai + vitri + i, 9].PutValue(ct.Giao_P_SanLuong);
                        _range[donghientai + vitri + i, 10].PutValue(ct.CosGiao);
                        _range[donghientai + vitri + i, 11].PutValue(ct.Nhan_P_Dau);
                        _range[donghientai + vitri + i, 12].PutValue(ct.Nhan_P_Cuoi);
                        _range[donghientai + vitri + i, 13].PutValue(ct.Nhan_P_SanLuong);
                        _range[donghientai + vitri + i, 14].PutValue(ct.CosNhan);
                    }
                    else if (i == 1)
                    {
                        _range[donghientai + vitri + i, 6].PutValue("Tổng Q");
                        _range[donghientai + vitri + i, 7].PutValue(ct.Giao_Q_Dau);
                        _range[donghientai + vitri + i, 8].PutValue(ct.Giao_Q_Cuoi);
                        _range[donghientai + vitri + i, 9].PutValue(ct.Giao_Q_SanLuong);
                        _range[donghientai + vitri + i, 10].PutValue("");
                        _range[donghientai + vitri + i, 11].PutValue(ct.Nhan_Q_Dau);
                        _range[donghientai + vitri + i, 12].PutValue(ct.Nhan_Q_Cuoi);
                        _range[donghientai + vitri + i, 13].PutValue(ct.Nhan_Q_SanLuong);
                        _range[donghientai + vitri + i, 14].PutValue("");
                    }
                    else if (i == 2)
                    {
                        _range[donghientai + vitri + i, 6].PutValue("Biểu 1");
                        _range[donghientai + vitri + i, 7].PutValue(ct.Giao_Bieu1_Dau);
                        _range[donghientai + vitri + i, 8].PutValue(ct.Giao_Bieu1_Cuoi);
                        _range[donghientai + vitri + i, 9].PutValue(ct.Giao_Bieu1_SanLuong);
                        _range[donghientai + vitri + i, 10].PutValue("");
                        _range[donghientai + vitri + i, 11].PutValue(ct.Nhan_Bieu1_Dau);
                        _range[donghientai + vitri + i, 12].PutValue(ct.Nhan_Bieu1_Cuoi);
                        _range[donghientai + vitri + i, 13].PutValue(ct.Nhan_Bieu1_SanLuong);
                        _range[donghientai + vitri + i, 14].PutValue("");
                    }
                    else if (i == 3)
                    {
                        _range[donghientai + vitri + i, 6].PutValue("Biểu 2");
                        _range[donghientai + vitri + i, 7].PutValue(ct.Giao_Bieu2_Dau);
                        _range[donghientai + vitri + i, 8].PutValue(ct.Giao_Bieu2_Cuoi);
                        _range[donghientai + vitri + i, 9].PutValue(ct.Giao_Bieu1_SanLuong);
                        _range[donghientai + vitri + i, 10].PutValue("");
                        _range[donghientai + vitri + i, 11].PutValue(ct.Nhan_Bieu2_Dau);
                        _range[donghientai + vitri + i, 12].PutValue(ct.Nhan_Bieu2_Cuoi);
                        _range[donghientai + vitri + i, 13].PutValue(ct.Nhan_Bieu2_SanLuong);
                        _range[donghientai + vitri + i, 14].PutValue("");
                    }
                    else if (i == 4)
                    {
                        _range[donghientai + vitri + i, 6].PutValue("Biểu 3");
                        _range[donghientai + vitri + i, 7].PutValue(ct.Giao_Bieu3_Dau);
                        _range[donghientai + vitri + i, 8].PutValue(ct.Giao_Bieu3_Cuoi);
                        _range[donghientai + vitri + i, 9].PutValue(ct.Giao_Bieu3_SanLuong);
                        _range[donghientai + vitri + i, 10].PutValue("");
                        _range[donghientai + vitri + i, 11].PutValue(ct.Nhan_Bieu3_Dau);
                        _range[donghientai + vitri + i, 12].PutValue(ct.Nhan_Bieu3_Cuoi);
                        _range[donghientai + vitri + i, 13].PutValue(ct.Nhan_Bieu3_SanLuong);
                        _range[donghientai + vitri + i, 14].PutValue("");
                    }
                }
                //in tổng
                _range[donghientai + vitri + 5, 1].PutValue("");
                _range.Merge(donghientai + vitri + 5, 1, 5, 1);
                _range[donghientai + vitri + 5, 1].SetStyle(celicaStil);
                var lstTong = db.BC_GiaoNhan2Chieu_TongTram(ma_dviqly, int.Parse("0" + cmbThang.Value), int.Parse("0" + cmbNam.Value)).ToList();
                var ctTong  = lstTong.SingleOrDefault(x => x.TenTram == ct.TenTram);
                if (ctTong != null)
                {
                    if (tongtram == ctTong.TongTram)
                    {
                        tongtram = 0;
                        for (int i = 0; i < 5; i++)
                        {
                            celicaStil.VerticalAlignment   = TextAlignmentType.Left;
                            celicaStil.HorizontalAlignment = TextAlignmentType.Left;
                            if (i == 0)
                            {
                                _range[donghientai + vitri + i + 5, 2].PutValue("Tổng P");
                                _range[donghientai + vitri + i + 5, 2].SetStyle(celicaStil);
                                _range.Merge(donghientai + vitri + i + 5, 2, 1, 7);

                                _range[donghientai + vitri + i + 5, 9].PutValue(ctTong.slPGiao);
                                _range[donghientai + vitri + i + 5, 13].PutValue(ctTong.slPNhan);

                                _range[donghientai + vitri + i + 5, 13].SetStyle(celicaStil);
                                _range[donghientai + vitri + i + 5, 9].SetStyle(celicaStil);
                            }
                            else if (i == 1)
                            {
                                _range[donghientai + vitri + i + 5, 2].PutValue("Tổng Q");
                                _range[donghientai + vitri + i + 5, 2].SetStyle(celicaStil);
                                _range.Merge(donghientai + vitri + i + 5, 2, 1, 7);
                                _range[donghientai + vitri + i + 5, 9].PutValue(ctTong.slQGiao);
                                _range[donghientai + vitri + i + 5, 13].PutValue(ctTong.slQNhan);
                                _range[donghientai + vitri + i + 5, 13].SetStyle(celicaStil);
                                _range[donghientai + vitri + i + 5, 9].SetStyle(celicaStil);
                            }
                            else if (i == 2)
                            {
                                _range[donghientai + vitri + i + 5, 2].PutValue("Tổng Biểu 1");
                                _range[donghientai + vitri + i + 5, 2].SetStyle(celicaStil);
                                _range.Merge(donghientai + vitri + i + 5, 2, 1, 7);
                                _range[donghientai + vitri + i + 5, 9].PutValue(ctTong.slb1Giao);
                                _range[donghientai + vitri + i + 5, 13].PutValue(ctTong.slb1Nhan);
                                _range[donghientai + vitri + i + 5, 13].SetStyle(celicaStil);
                                _range[donghientai + vitri + i + 5, 9].SetStyle(celicaStil);
                            }
                            else if (i == 3)
                            {
                                _range[donghientai + vitri + i + 5, 2].PutValue("Tổng Biểu 2");
                                _range[donghientai + vitri + i + 5, 2].SetStyle(celicaStil);
                                _range.Merge(donghientai + vitri + i + 5, 2, 1, 7);

                                _range[donghientai + vitri + i + 5, 9].PutValue(ctTong.slb2Giao);
                                _range[donghientai + vitri + i + 5, 13].PutValue(ctTong.slb2Nhan);
                                _range[donghientai + vitri + i + 5, 13].SetStyle(celicaStil);
                                _range[donghientai + vitri + i + 5, 9].SetStyle(celicaStil);
                            }
                            else if (i == 4)
                            {
                                _range[donghientai + vitri + i + 5, 2].PutValue("Tổng Biểu 3");
                                _range[donghientai + vitri + i + 5, 2].SetStyle(celicaStil);
                                _range.Merge(donghientai + vitri + i + 5, 2, 1, 7);

                                _range[donghientai + vitri + i + 5, 9].PutValue(ctTong.slb3Giao);
                                _range[donghientai + vitri + i + 5, 13].PutValue(ctTong.slb3Nhan);
                                _range[donghientai + vitri + i + 5, 13].SetStyle(celicaStil);
                                _range[donghientai + vitri + i + 5, 9].SetStyle(celicaStil);
                            }
                            else if (i == 5)
                            {
                                _range[donghientai + vitri + i + 5, 2].PutValue("Tổng 3 Biểu");
                                _range[donghientai + vitri + i + 5, 2].SetStyle(celicaStil);
                                _range.Merge(donghientai + vitri + i + 5, 2, 1, 7);
                                _range[donghientai + vitri + i + 5, 9].PutValue(ctTong.tong3B_Giao);
                                _range[donghientai + vitri + i + 5, 13].PutValue(ctTong.tong3B_Nhan);
                                _range[donghientai + vitri + i + 5, 13].SetStyle(celicaStil);
                                _range[donghientai + vitri + i + 5, 9].SetStyle(celicaStil);
                            }
                        }
                        vitri = vitri + 5;
                    }
                }
                vitri = vitri + 5;
            }

            #endregion

            exBook.Save("BC_KhuVuc.xls", SaveType.OpenInExcel, FileFormatType.Default, this.Response);
            //Response.Redirect("../BaoCao/Report.aspx?Loai=5&strSQL=" + strTruyVan);
        }
Beispiel #23
0
        protected void btnXuatFile_Click(object sender, EventArgs e)
        {
            if (rdImportDuLieu.SelectedIndex == 0)
            {
                try
                {
                    SYS_Session session     = (SYS_Session)Session["SYS_Session"];
                    string      strMadviqly = session.User.ma_dviqly;
                    DataSet     dsTem       = new DataSet();

                    DataAccess.dbGCS dataA = new DataAccess.dbGCS();

                    //MemoryStream memStream = new MemoryStream();
                    //Stream file = Server.MapPath("~/") + "FileGCSCMIS\\" + UploadFile();
                    //using (Stream s = file.PostedFile.InputStream)
                    //{
                    //    s.CopyTo(memStream);
                    //}

                    dsTem.ReadXml(Server.MapPath("~/") + "FileGCSCMIS\\" + UploadFile(), XmlReadMode.InferSchema);

                    for (int i = 0; i < dsTem.Tables[0].Rows.Count; i++)
                    {
                        CBDN.CMIS_DDoGC ddo        = new CBDN.CMIS_DDoGC();
                        CBDN.CMIS_DDoGC kiemtraDDo = new CBDN.CMIS_DDoGC();
                        kiemtraDDo = dbSQL.CMIS_DDoGCs.SingleOrDefault(x => x.MA_DVIQLY == dsTem.Tables[0].Rows[i]["MA_DVIQLY"] + "" && x.MA_DDO == dsTem.Tables[0].Rows[i]["MA_DDO"] + "" && x.THANG == int.Parse(dsTem.Tables[0].Rows[i]["THANG"] + "") && x.NAM == int.Parse(dsTem.Tables[0].Rows[i]["NAM"] + "") && x.LOAI_BCS == dsTem.Tables[0].Rows[i]["LOAI_BCS"] + "");
                        if (kiemtraDDo == null)
                        {
                            ddo.MA_NVGCS   = dsTem.Tables[0].Rows[i]["MA_NVGCS"] + "";
                            ddo.BOCSO_ID   = dsTem.Tables[0].Rows[i]["BOCSO_ID"] + "";
                            ddo.CHUOI_GIA  = dsTem.Tables[0].Rows[i]["CHUOI_GIA"] + "";
                            ddo.CS_CU      = decimal.Parse(dsTem.Tables[0].Rows[i]["CS_CU"] + "");
                            ddo.CS_MOI     = decimal.Parse(dsTem.Tables[0].Rows[i]["CS_MOI"] + "");
                            ddo.DIA_CHI    = dsTem.Tables[0].Rows[i]["DIA_CHI"] + "";
                            ddo.HSN        = decimal.Parse(dsTem.Tables[0].Rows[i]["HSN"] + "");
                            ddo.KIMUA_CSPK = decimal.Parse(dsTem.Tables[0].Rows[i]["KIMUA_CSPK"] + "");
                            ddo.KY         = int.Parse(dsTem.Tables[0].Rows[i]["KY"] + "");
                            ddo.LOAI_BCS   = dsTem.Tables[0].Rows[i]["LOAI_BCS"] + "";

                            ddo.LOAI_CS   = dsTem.Tables[0].Rows[i]["LOAI_CS"] + "";
                            ddo.MA_CNANG  = "";
                            ddo.MA_COT    = dsTem.Tables[0].Rows[i]["MA_COT"] + "";
                            ddo.MA_CTO    = dsTem.Tables[0].Rows[i]["MA_CTO"] + "";
                            ddo.MA_DDO    = dsTem.Tables[0].Rows[i]["MA_DDO"] + "";
                            ddo.MA_DVIQLY = dsTem.Tables[0].Rows[i]["MA_DVIQLY"] + "";
                            ddo.MA_GC     = dsTem.Tables[0].Rows[i]["MA_GC"] + "";
                            ddo.MA_KHANG  = dsTem.Tables[0].Rows[i]["MA_KHANG"] + "";
                            ddo.MA_NVGCS  = dsTem.Tables[0].Rows[i]["MA_NVGCS"] + "";
                            ddo.MA_NVIEN  = "";
                            ddo.MA_SOGCS  = dsTem.Tables[0].Rows[i]["MA_QUYEN"] + "";
                            ddo.MA_TRAM   = dsTem.Tables[0].Rows[i]["MA_TRAM"] + "";
                            ddo.NAM       = int.Parse(dsTem.Tables[0].Rows[i]["NAM"] + "");
                            ddo.NGAY_CU   = DateTime.Parse(dsTem.Tables[0].Rows[i]["NGAY_CU"] + "");
                            ddo.NGAY_MOI  = DateTime.Parse(dsTem.Tables[0].Rows[i]["NGAY_MOI"] + "");
                            ddo.NGAY_PMAX = DateTime.Parse(dsTem.Tables[0].Rows[i]["NGAY_PMAX"] + "");
                            ddo.NGUOI_GCS = dsTem.Tables[0].Rows[i]["NGUOI_GCS"] + "";
                            ddo.PMAX      = decimal.Parse(dsTem.Tables[0].Rows[i]["PMAX"] + "");
                            ddo.SERY_CTO  = dsTem.Tables[0].Rows[i]["SERY_CTO"] + "";
                            ddo.SL_MOI    = decimal.Parse(dsTem.Tables[0].Rows[i]["SL_MOI"] + "");
                            ddo.SL_THAO   = decimal.Parse(dsTem.Tables[0].Rows[i]["SL_THAO"] + "");
                            ddo.SL_TTIEP  = decimal.Parse(dsTem.Tables[0].Rows[i]["SL_TTIEP"] + "");
                            ddo.SLUONG_1  = decimal.Parse(dsTem.Tables[0].Rows[i]["SLUONG_1"] + "");
                            ddo.SLUONG_2  = decimal.Parse(dsTem.Tables[0].Rows[i]["SLUONG_2"] + "");
                            ddo.SLUONG_3  = decimal.Parse(dsTem.Tables[0].Rows[i]["SLUONG_3"] + "");

                            ddo.SO_HO     = Convert.ToInt32(Convert.ToDecimal(dsTem.Tables[0].Rows[i]["SO_HO"] + ""));
                            ddo.SO_HOM    = dsTem.Tables[0].Rows[i]["SO_HOM"] + "";
                            ddo.TEN_KHANG = dsTem.Tables[0].Rows[i]["TEN_KHANG"] + "";
                            ddo.THANG     = int.Parse(dsTem.Tables[0].Rows[i]["THANG"] + "");
                            ddo.TTR_CU    = dsTem.Tables[0].Rows[i]["TTR_MOI"] + "";
                            ddo.TENFILE   = fileUp.FileName;
                            dbSQL.CMIS_DDoGCs.InsertOnSubmit(ddo);
                            dbSQL.SubmitChanges();
                        }
                    }
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Nhận dữ liệu thành công');", true);
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Lỗi nhận dữ liệu: " + ex.Message + "');", true);
                }
            }
            else
            {
                SYS_Session session     = (SYS_Session)Session["SYS_Session"];
                string      strMadviqly = session.User.ma_dviqly;

                DM_DVQLYService _DM_DVQLY = new DM_DVQLYService();
                var             dv        = _DM_DVQLY.SelectDM_DVQLY(int.Parse(strMadviqly));

                var lst = dbSQL.CMIS_DDoGCs.Where(x => x.MA_DVIQLY == dv.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + ""));
                foreach (var ddo in lst)
                {
                    var diemdo = dbSQL.DM_DiemDos.SingleOrDefault(x => x.MaDiemDo == ddo.MA_DDO && x.HoatDong == 1);
                    if (diemdo == null)
                    {
                        continue;
                    }
                    var kiemtra = dbSQL.DM_CongTos.SingleOrDefault(x => x.IDDiemDo == diemdo.IDDiemDo + "" && x.TinhTrang == 1);
                    if (kiemtra == null)
                    {
                        continue;
                    }
                    var hhddo = dbSQL.HD_GiaoNhanThangs.SingleOrDefault(x => x.IDCongTo == kiemtra.IDCongTo + "" && x.Thang == int.Parse(cmbThang.Value + "") && x.Nam == int.Parse(cmbNam.Value + ""));
                    if (hhddo == null)
                    {
                        continue;
                    }

                    if (ddo.LOAI_BCS == "BT")
                    {
                        var diemdocmis = dbSQL.CMIS_DDoGCs.SingleOrDefault(x => x.MA_DVIQLY == dv.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + "") && x.MA_DDO == diemdo.MaDiemDo && x.LOAI_BCS == "BT");

                        diemdocmis.CS_MOI          = hhddo.Giao_Bieu1_Cuoi;
                        diemdocmis.SL_MOI          = hhddo.Giao_Bieu1_SanLuong;
                        diemdocmis.TrangThaiDongBo = 1;
                        dbSQL.SubmitChanges();
                    }
                    else if (ddo.LOAI_BCS == "CD")
                    {
                        var diemdocmis = dbSQL.CMIS_DDoGCs.SingleOrDefault(x => x.MA_DVIQLY == dv.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + "") && x.MA_DDO == diemdo.MaDiemDo && x.LOAI_BCS == "CD");

                        diemdocmis.CS_MOI          = hhddo.Giao_Bieu2_Cuoi;
                        diemdocmis.SL_MOI          = hhddo.Giao_Bieu2_SanLuong;
                        diemdocmis.TrangThaiDongBo = 1;
                        dbSQL.SubmitChanges();
                    }
                    else if (ddo.LOAI_BCS == "TD")
                    {
                        var diemdocmis = dbSQL.CMIS_DDoGCs.SingleOrDefault(x => x.MA_DVIQLY == dv.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + "") && x.MA_DDO == diemdo.MaDiemDo && x.LOAI_BCS == "TD");

                        diemdocmis.CS_MOI          = hhddo.Giao_Bieu3_Cuoi;
                        diemdocmis.SL_MOI          = hhddo.Giao_Bieu3_SanLuong;
                        diemdocmis.TrangThaiDongBo = 1;
                        dbSQL.SubmitChanges();
                    }
                    else if (ddo.LOAI_BCS == "VC")
                    {
                        var diemdocmis = dbSQL.CMIS_DDoGCs.SingleOrDefault(x => x.MA_DVIQLY == dv.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + "") && x.MA_DDO == diemdo.MaDiemDo && x.LOAI_BCS == "VC");

                        diemdocmis.CS_MOI          = hhddo.Giao_Q_Cuoi;
                        diemdocmis.SL_MOI          = hhddo.Giao_Q_SanLuong;
                        diemdocmis.TrangThaiDongBo = 1;
                        dbSQL.SubmitChanges();
                    }

                    if (ddo.LOAI_BCS == "BN")
                    {
                        var diemdocmis = dbSQL.CMIS_DDoGCs.SingleOrDefault(x => x.MA_DVIQLY == dv.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + "") && x.MA_DDO == diemdo.MaDiemDo && x.LOAI_BCS == "BN");

                        diemdocmis.CS_MOI          = hhddo.Nhan_Bieu1_Cuoi;
                        diemdocmis.SL_MOI          = hhddo.Nhan_Bieu1_SanLuong;
                        diemdocmis.TrangThaiDongBo = 1;
                        dbSQL.SubmitChanges();
                    }
                    else if (ddo.LOAI_BCS == "CN")
                    {
                        var diemdocmis = dbSQL.CMIS_DDoGCs.SingleOrDefault(x => x.MA_DVIQLY == dv.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + "") && x.MA_DDO == diemdo.MaDiemDo && x.LOAI_BCS == "CN");

                        diemdocmis.CS_MOI          = hhddo.Nhan_Bieu2_Cuoi;
                        diemdocmis.SL_MOI          = hhddo.Nhan_Bieu2_SanLuong;
                        diemdocmis.TrangThaiDongBo = 1;
                        dbSQL.SubmitChanges();
                    }
                    else if (ddo.LOAI_BCS == "TN")
                    {
                        var diemdocmis = dbSQL.CMIS_DDoGCs.SingleOrDefault(x => x.MA_DVIQLY == dv.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + "") && x.MA_DDO == diemdo.MaDiemDo && x.LOAI_BCS == "TN");

                        diemdocmis.CS_MOI          = hhddo.Nhan_Bieu3_Cuoi;
                        diemdocmis.SL_MOI          = hhddo.Nhan_Bieu3_SanLuong;
                        diemdocmis.TrangThaiDongBo = 1;
                        dbSQL.SubmitChanges();
                    }
                    else if (ddo.LOAI_BCS == "VN")
                    {
                        var diemdocmis = dbSQL.CMIS_DDoGCs.SingleOrDefault(x => x.MA_DVIQLY == dv.MA_DVIQLY && x.THANG == int.Parse(cmbThang.Value + "") && x.NAM == int.Parse(cmbNam.Value + "") && x.MA_DDO == diemdo.MaDiemDo && x.LOAI_BCS == "VN");

                        diemdocmis.CS_MOI          = hhddo.Nhan_Q_Cuoi;
                        diemdocmis.SL_MOI          = hhddo.Nhan_Q_SanLuong;
                        diemdocmis.TrangThaiDongBo = 1;
                        dbSQL.SubmitChanges();
                    }
                }
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Đồng bộ số liệu thành công');", true);
                loadDLDongBo();
            }
        }
Beispiel #24
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            DM_DVQLYService dm_dviSer = new DM_DVQLYService();
            SYS_Session     session   = (SYS_Session)Session["SYS_Session"];

            if (cmbCuoiNguon.Value == null)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Bạn chưa chọn đơn vị');", true);
                cmbCuoiNguon.Focus();
                return;
            }
            if (txtSoTram.Text + "" == "")
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Bạn phải nhập số khách hàng đang có điện áp thấp');", true);
                txtSoTram.Focus(); return;
            }
            int testInt = 0;

            if (!int.TryParse(txtSoTram.Text + "", out testInt))
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Số khách hàng đang có điện áp thấp phải là kiểu số');", true);
                txtSoTram.Focus(); return;
            }
            if (!int.TryParse(txtSoKh160.Text + "", out testInt))
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Số khách hàng SH có điện áp thấp < 160kV');", true);
                txtSoKh160.Focus(); return;
            }
            if (!int.TryParse(txtSoKH180.Text + "", out testInt))
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Số khách hàng SH có điện áp thấp từ 160kV -180kv');", true);
                txtSoKH180.Focus(); return;
            }
            if (!int.TryParse(txtSoKH200.Text + "", out testInt))
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Số khách hàng SH có điện áp thấp trên 200kv');", true);
                txtSoKH200.Focus(); return;
            }
            string dvdaunguon  = dm_dviSer.SelectDM_DVQLY(int.Parse(session.User.ma_dviqly)).MA_DVIQLY;
            string dvcuoinguon = dm_dviSer.SelectDM_DVQLY(int.Parse(cmbCuoiNguon.Value + "")).MA_DVIQLY;

            if (Session["Add"] + "" == "0")
            {
                CBDN.TT_KhachHangDAThapTrongThangResult qtCT = (CBDN.TT_KhachHangDAThapTrongThangResult)grdDVT.GetRow(grdDVT.FocusedRowIndex);

                CBDN.TT_KhachHangDAThap cn = db.TT_KhachHangDAThaps.SingleOrDefault(x => x.ID == qtCT.ID);

                cn.SoTBA          = int.Parse(txtSoTram.Text);
                cn.KH160          = int.Parse(txtSoKh160.Value + "");
                cn.KH180          = int.Parse(txtSoKH180.Value + "");
                cn.KH200          = int.Parse(txtSoKH200.Value + "");
                cn.Nam            = int.Parse(cmbNam.Value + "");
                cn.Thang          = int.Parse(cmbThang.Value + "");
                cn.TienDoThucHien = txtTienDo.Text;
                cn.GiaiPhap       = txtGiaiPhap.Text;
                cn.IDMA_DVIQLY    = int.Parse(cmbCuoiNguon.Value + "");
                db.SubmitChanges();

                //}
            }
            else
            {
                if (!CheckName(int.Parse(cmbCuoiNguon.Value + ""), int.Parse(cmbThang.Value + ""), int.Parse("" + cmbNam.Value)))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã phương thức giao nhận được trùng');", true); return;
                }

                CBDN.TT_KhachHangDAThap cv = new CBDN.TT_KhachHangDAThap();
                cv.SoTBA          = int.Parse(txtSoTram.Text);
                cv.KH160          = int.Parse(txtSoKh160.Value + "");
                cv.KH180          = int.Parse(txtSoKH180.Value + "");
                cv.KH200          = int.Parse(txtSoKH200.Value + "");
                cv.Nam            = int.Parse(cmbNam.Value + "");
                cv.Thang          = int.Parse(cmbThang.Value + "");
                cv.TienDoThucHien = txtTienDo.Text;
                cv.GiaiPhap       = txtGiaiPhap.Text;
                cv.IDMA_DVIQLY    = int.Parse(cmbCuoiNguon.Value + "");
                db.TT_KhachHangDAThaps.InsertOnSubmit(cv);
                db.SubmitChanges();
            }
            pcAddRoles.ShowOnPageLoad = false;
            _DataBind();
        }
Beispiel #25
0
        protected void btnXuat_Click(object sender, EventArgs e)
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int ma_dviqly = int.Parse(session.User.ma_dviqly + "");

            var lst     = db.BC_TonThat_ChiTietCDA(ma_dviqly, int.Parse("0" + cmbThang.Value), int.Parse("0" + cmbNam.Value), cmbCapDienAp.Value + "").ToList();
            var lsttONG = db.BC_TonThatCDA(ma_dviqly, int.Parse("0" + cmbThang.Value), int.Parse("0" + cmbNam.Value), cmbCapDienAp.Value + "").ToList();

            #region Chuẩn bị tệp excel mẫu để ghi dữ liệu
            string   destFile  = Server.MapPath("~/Tem/BC_TonThat.xls");
            string   sTemplate = (destFile);
            Workbook exBook    = new Workbook();
            exBook.Open(sTemplate, FileFormatType.Excel2003);
            _exSheet = exBook.Worksheets[0];
            _range   = _exSheet.Cells;
            #endregion

            // Xử lý replace các thông tin báo cáo tĩnh theo công ty
            //Report.ReplaceSpecificationField(_exSheet);

            int donghientai = 7;

            #region Ghi dữ liệu
            _exSheet.Replace("ntNgayThang", "Ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year);

            Style celicaStil = exBook.Styles[exBook.Styles.Add()];
            celicaStil.Font.IsBold = true;

            DM_DVQLYService dm_dviSer = new DM_DVQLYService();
            var             donvi     = dm_dviSer.SelectDM_DVQLY(ma_dviqly);

            _exSheet.Replace("ntDienLuc", donvi.NAME_DVIQLY.Split('-')[1].ToUpper());

            _exSheet.Replace("ntTieuDe", "BÁO CÁO SẢN LƯỢNG ĐIỆN GIAO CỦA " + donvi.NAME_DVIQLY.Split('-')[1].ToString().ToUpper() + " TRONG THÁNG " + cmbThang.Value + " NĂM " + cmbNam.Value);

            if (lst.Count > 0)
            {
                _exSheet.Cells.InsertRows(donghientai + 1, lst.Count);
            }

            int    stt        = 1;
            string tenchinhan = "";
            foreach (var chitiet in lst)
            {
                _range[donghientai + stt, 0].PutValue(stt);
                if (tenchinhan != chitiet.TenChiNhanh)
                {
                    var soTCN = lst.Where(x => x.TenChiNhanh == chitiet.TenChiNhanh);
                    _range[donghientai + stt, 1].PutValue(chitiet.TenChiNhanh);
                    _range.Merge(donghientai + stt, 1, soTCN.Count(), 1);
                    _range[donghientai + stt, 1].SetStyle(celicaStil);
                    tenchinhan = chitiet.TenChiNhanh;
                }


                _range[donghientai + stt, 2].PutValue(chitiet.MaDiemDo + "-" + chitiet.TenDiemDo);
                _range[donghientai + stt, 3].PutValue(chitiet.Nhan_Bieu1_SanLuong);
                _range[donghientai + stt, 4].PutValue(chitiet.Giao_Bieu1_SanLuong);
                _range[donghientai + stt, 5].PutValue(chitiet.Nhan_Bieu2_SanLuong);
                _range[donghientai + stt, 6].PutValue(chitiet.Giao_Bieu2_SanLuong);
                _range[donghientai + stt, 7].PutValue(chitiet.Nhan_Bieu3_SanLuong);
                _range[donghientai + stt, 8].PutValue(chitiet.Giao_Bieu3_SanLuong);
                _range[donghientai + stt, 9].PutValue(chitiet.TongNhan3B);
                _range[donghientai + stt, 10].PutValue(chitiet.TongGiao3B);
                stt++;
            }
            foreach (var chitiet in lsttONG)
            {
                _range[donghientai + stt, 0].PutValue("Tổng");
                _range.Merge(donghientai + stt, 0, 1, 3);
                _range[donghientai + stt, 3].PutValue(chitiet.NhanB1);
                _range[donghientai + stt, 4].PutValue(chitiet.GiaoB1);
                _range[donghientai + stt, 5].PutValue(chitiet.NhanB2);
                _range[donghientai + stt, 6].PutValue(chitiet.GiaoB2);
                _range[donghientai + stt, 7].PutValue(chitiet.NhanB3);
                _range[donghientai + stt, 8].PutValue(chitiet.GiaoB3);
                _range[donghientai + stt, 9].PutValue(chitiet.TongN3B);
                _range[donghientai + stt, 10].PutValue(chitiet.TongG3B);
                stt++;

                _range[donghientai + stt, 0].PutValue("Tổn hao");
                _range.Merge(donghientai + stt, 0, 1, 3);
                _range[donghientai + stt, 3].PutValue(chitiet.TonHao1);
                _range.Merge(donghientai + stt, 3, 1, 2);
                _range[donghientai + stt, 5].PutValue(chitiet.TonHao2);
                _range.Merge(donghientai + stt, 5, 1, 2);
                _range[donghientai + stt, 7].PutValue(chitiet.TonHao3);
                _range.Merge(donghientai + stt, 7, 1, 2);
                _range[donghientai + stt, 9].PutValue(chitiet.TonHaoTong);
                _range.Merge(donghientai + stt, 9, 1, 2);
                stt++;

                _range[donghientai + stt, 0].PutValue("Tổng thất công ty");
                _range.Merge(donghientai + stt, 0, 1, 3);
                _range[donghientai + stt, 3].PutValue(chitiet.TiLeTonThatB1);
                _range.Merge(donghientai + stt, 3, 1, 2);
                _range[donghientai + stt, 5].PutValue(chitiet.TiLeTonThatB2);
                _range.Merge(donghientai + stt, 5, 1, 2);
                _range[donghientai + stt, 7].PutValue(chitiet.TiLeTonThatb3);
                _range.Merge(donghientai + stt, 7, 1, 2);
                _range[donghientai + stt, 9].PutValue(chitiet.TiLeTonThat);
                _range.Merge(donghientai + stt, 9, 1, 2);

                break;
            }


            #endregion

            exBook.Save("bc_dienLuc.xls", SaveType.OpenInExcel, FileFormatType.Default, this.Response);
            //Response.Redirect("../BaoCao/Report.aspx?Loai=5&strSQL=" + strTruyVan);
        }
Beispiel #26
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            DM_DVQLYService dm_dviSer  = new DM_DVQLYService();
            SYS_Session     session    = (SYS_Session)Session["SYS_Session"];
            string          dvdaunguon = dm_dviSer.SelectDM_DVQLY(int.Parse(session.User.ma_dviqly)).MA_DVIQLY;

            if (Session["Add"] + "" == "0")
            {
                CBDN.DM_ChiNhanhSelectByIDDViResult cv = (CBDN.DM_ChiNhanhSelectByIDDViResult)grdDVT.GetRow(grdDVT.FocusedRowIndex);
                var lst = db.DM_ChiNhanhs.Where(x => x.MaChiNhanh == cv.MaChiNhanh);
                foreach (var qtCT in lst)
                {
                    if (!CheckName(txtMaDuongDat.Text, cv.ID))
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã phương thức giao nhận được trùng');", true); return;
                    }

                    qtCT.TenChiNhanh = txtmoTa.Text;
                    qtCT.MoTa        = txtmoTa.Text;
                    if (CkHoatDong.Checked)
                    {
                        qtCT.HoatDong = 1;
                    }
                    else
                    {
                        qtCT.HoatDong = 0;
                    }
                    db.SubmitChanges();
                }
            }
            else
            {
                if (txtMaDuongDat.Text + "" == "")
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã chi nhánh không được để trống');", true);
                    txtMaDuongDat.Focus(); return;
                }

                if (!CheckName(txtMaDuongDat.Text, 0))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã chi nhánh không được trùng');", true); return;
                }

                CBDN.DM_ChiNhanh cv = new CBDN.DM_ChiNhanh();
                cv.TenChiNhanh   = txtmoTa.Text;
                cv.MaChiNhanh    = txtMaDuongDat.Text;
                cv.IDMADVIQLY    = int.Parse(session.User.ma_dviqly);
                cv.MoTa          = txtmoTa.Text;
                cv.DiemDauNguon  = int.Parse(session.User.ma_dviqly);
                cv.DiemCuoiNguon = int.Parse(session.User.ma_dviqly);
                if (CkHoatDong.Checked)
                {
                    cv.HoatDong = 1;
                }
                else
                {
                    cv.HoatDong = 0;
                }
                cv.ISNhaMay   = true;
                cv.LoaiNhaMay = int.Parse(cmbloaiGiaoNhan.Value + "");
                db.DM_ChiNhanhs.InsertOnSubmit(cv);
                db.SubmitChanges();
            }
            pcAddRoles.ShowOnPageLoad = false;
            _DataBind();
        }
Beispiel #27
0
        protected void btnXuat_Click(object sender, EventArgs e)
        {
            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            int ma_dviqly = int.Parse(session.User.ma_dviqly + "");

            var lst     = db.BC_ChiSoThang_ChuaChot(ma_dviqly, int.Parse("0" + cmbThang.Value), int.Parse("0" + cmbNam.Value)).ToList();
            var lsttONG = db.BC_GiaoNhan2Chieu_TongTram(ma_dviqly, int.Parse("0" + cmbThang.Value), int.Parse("0" + cmbNam.Value)).ToList();

            #region Chuẩn bị tệp excel mẫu để ghi dữ liệu
            string   destFile  = Server.MapPath("~/Tem/BC_BCDienLuc.xls");
            string   sTemplate = (destFile);
            Workbook exBook    = new Workbook();
            exBook.Open(sTemplate, FileFormatType.Excel2003);
            _exSheet = exBook.Worksheets[0];
            _range   = _exSheet.Cells;
            #endregion

            // Xử lý replace các thông tin báo cáo tĩnh theo công ty
            //Report.ReplaceSpecificationField(_exSheet);

            int donghientai = 7;

            #region Ghi dữ liệu
            _exSheet.Replace("NGAYTHANG", "Ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year);

            Style celicaStil = exBook.Styles[exBook.Styles.Add()];
            celicaStil.Font.IsBold = true;

            DM_DVQLYService dm_dviSer = new DM_DVQLYService();
            var             donvi     = dm_dviSer.SelectDM_DVQLY(ma_dviqly);

            _exSheet.Replace("ntDienLuc", donvi.NAME_DVIQLY.Split('-')[1].ToUpper());

            _exSheet.Replace("ntTieuDe", "BÁO CÁO SẢN LƯỢNG ĐIỆN GIAO CỦA " + donvi.NAME_DVIQLY.Split('-')[1].ToString().ToUpper() + " TRONG THÁNG " + cmbThang.Value + " NĂM " + cmbNam.Value);

            if (lst.Count > 0)
            {
                _exSheet.Cells.InsertRows(donghientai + 1, (lst.Count + lsttONG.Count * 2) - 3);
            }
            string idTram = "0"; int vitri = 0;
            int    sttTong = 0, sttChiTiet = 0;
            foreach (var tongtram in lsttONG)
            {
                if (idTram != tongtram.IDTram + "")
                {
                    var tram = db.DM_Trams.SingleOrDefault(x => x.IDTram == tongtram.IDTram);
                    if (tram == null)
                    {
                        continue;
                    }
                    var phuongthuc = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(tram.IDChiNhanh));
                    if (phuongthuc == null)
                    {
                        continue;
                    }
                    _range[donghientai + vitri, 0].PutValue(phuongthuc.MoTa);
                    _range.Merge(donghientai + vitri, 0, 1, 21);
                    _range[donghientai + vitri, 0].SetStyle(celicaStil);

                    vitri   = vitri + 1;
                    sttTong = sttTong + 1;
                    _range[donghientai + vitri, 0].PutValue(sttTong);
                    _range[donghientai + vitri, 0].SetStyle(celicaStil);
                    _range[donghientai + vitri, 1].PutValue(tongtram.TenTram);
                    _range[donghientai + vitri, 1].SetStyle(celicaStil);
                    _range[donghientai + vitri, 7].PutValue(tongtram.slPGiao);
                    _range[donghientai + vitri, 7].SetStyle(celicaStil);
                    _range[donghientai + vitri, 11].PutValue(tongtram.slb1Giao);
                    _range[donghientai + vitri, 11].SetStyle(celicaStil);
                    _range[donghientai + vitri, 15].PutValue(tongtram.slb2Giao);
                    _range[donghientai + vitri, 15].SetStyle(celicaStil);
                    _range[donghientai + vitri, 19].PutValue(tongtram.slb3Giao);
                    _range[donghientai + vitri, 19].SetStyle(celicaStil);
                    vitri = vitri + 1;
                    var lstByTram = lst.Where(x => x.IDTram == tongtram.IDTram).ToList();
                    sttChiTiet = sttChiTiet + 1;
                    foreach (var chitiet in lstByTram)
                    {
                        _range[donghientai + vitri, 0].PutValue(sttTong + "." + sttChiTiet);
                        _range[donghientai + vitri, 1].PutValue(chitiet.TenDiemDo);
                        _range[donghientai + vitri, 2].PutValue(chitiet.CapDienAp);
                        _range[donghientai + vitri, 3].PutValue(chitiet.HeSoNhan);
                        _range[donghientai + vitri, 4].PutValue(chitiet.Giao_P_Dau);
                        _range[donghientai + vitri, 5].PutValue(chitiet.Giao_P_Cuoi);
                        _range[donghientai + vitri, 6].PutValue(chitiet.Giao_P_Cuoi - chitiet.Giao_P_Dau);
                        _range[donghientai + vitri, 7].PutValue(chitiet.Giao_P_SanLuong);

                        _range[donghientai + vitri, 8].PutValue(chitiet.Giao_Bieu1_Dau);
                        _range[donghientai + vitri, 9].PutValue(chitiet.Giao_Bieu1_Cuoi);
                        _range[donghientai + vitri, 10].PutValue(chitiet.Giao_Bieu1_Cuoi - chitiet.Giao_Bieu1_Dau);
                        _range[donghientai + vitri, 11].PutValue(chitiet.Giao_Bieu1_SanLuong);

                        _range[donghientai + vitri, 12].PutValue(chitiet.Giao_Bieu2_Dau);
                        _range[donghientai + vitri, 13].PutValue(chitiet.Giao_Bieu2_Cuoi);
                        _range[donghientai + vitri, 14].PutValue(chitiet.Giao_Bieu2_Cuoi - chitiet.Giao_Bieu2_Dau);
                        _range[donghientai + vitri, 15].PutValue(chitiet.Giao_Bieu2_SanLuong);

                        _range[donghientai + vitri, 16].PutValue(chitiet.Giao_Bieu3_Dau);
                        _range[donghientai + vitri, 17].PutValue(chitiet.Giao_Bieu3_Cuoi);
                        _range[donghientai + vitri, 18].PutValue(chitiet.Giao_Bieu3_Cuoi - chitiet.Giao_Bieu3_Dau);
                        _range[donghientai + vitri, 19].PutValue(chitiet.Giao_Bieu3_SanLuong);

                        vitri = vitri + 1;
                    }
                    idTram = tongtram.IDTram + "";
                }
            }


            #endregion

            exBook.Save("bc_dienLuc.xls", SaveType.OpenInExcel, FileFormatType.Default, this.Response);
            //Response.Redirect("../BaoCao/Report.aspx?Loai=5&strSQL=" + strTruyVan);
        }
Beispiel #28
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            DM_DVQLYService dm_dviSer   = new DM_DVQLYService();
            SYS_Session     session     = (SYS_Session)Session["SYS_Session"];
            string          dvdaunguon  = dm_dviSer.SelectDM_DVQLY(int.Parse(session.User.ma_dviqly)).MA_DVIQLY;
            string          dvcuoinguon = dm_dviSer.SelectDM_DVQLY(int.Parse(cmbCuoiNguon.Value + "")).MA_DVIQLY;

            if (Session["Add"] + "" == "0")
            {
                CBDN.DM_ChiNhanhSelectByIDDViResult qtCT = (CBDN.DM_ChiNhanhSelectByIDDViResult)grdDVT.GetRow(grdDVT.FocusedRowIndex);
                //var lst = db.DM_ChiNhanhs.Where(x => x.MaChiNhanh == cv.MaChiNhanh);
                //foreach (var qtCT in lst)
                //{
                CBDN.DM_ChiNhanh cn = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == qtCT.ID);
                if (!CheckName(txtMaDuongDat.Text, qtCT.ID))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã phương thức giao nhận được trùng');", true); return;
                }

                cn.TenChiNhanh    = txtmoTa.Text;
                cn.LoaiPhuongThuc = int.Parse(cmbLoaiPhuongThuc.Value + "");
                cn.MoTa           = txtmoTa.Text;
                if (CkHoatDong.Checked)
                {
                    cn.HoatDong = 1;
                }
                else
                {
                    cn.HoatDong = 0;
                }
                db.SubmitChanges();
                //}
            }
            else
            {
                if (txtMaDuongDat.Text + "" == "")
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã chi nhánh không được để trống');", true);
                    txtMaDuongDat.Focus(); return;
                }
                //if (txtTenDuongDay.Text == "")
                //{
                //    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Tên chi nhánh không được để trống');", true);
                //    txtTenDuongDay.Focus(); return;
                //}

                if (!CheckName(txtMaDuongDat.Text, 0))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã chi nhánh không được trùng');", true); return;
                }

                CBDN.DM_ChiNhanh cv = new CBDN.DM_ChiNhanh();
                cv.TenChiNhanh = txtmoTa.Text;
                cv.MaChiNhanh  = dvdaunguon + "_" + dvcuoinguon;
                if (session.User.ma_dviqly != "" + cmbCuoiNguon.Value)
                {
                    cv.IDMADVIQLY = "," + session.User.ma_dviqly + "," + cmbCuoiNguon.Value + ",";
                }
                else
                {
                    cv.IDMADVIQLY = session.User.ma_dviqly;
                }
                cv.LoaiPhuongThuc = int.Parse(cmbLoaiPhuongThuc.Value + "");
                cv.MoTa           = txtmoTa.Text;
                cv.DiemDauNguon   = int.Parse(session.User.ma_dviqly);
                cv.DiemCuoiNguon  = int.Parse(cmbCuoiNguon.Value + "");
                if (CkHoatDong.Checked)
                {
                    cv.HoatDong = 1;
                }
                else
                {
                    cv.HoatDong = 0;
                }
                db.DM_ChiNhanhs.InsertOnSubmit(cv);
                db.SubmitChanges();


                //CBDN.DM_ChiNhanh cnGiaoNhan = new CBDN.DM_ChiNhanh();
                //cnGiaoNhan.TenChiNhanh = txtmoTa.Text;
                //cnGiaoNhan.MaChiNhanh = dvdaunguon + "_" + dvcuoinguon;
                //cnGiaoNhan.IDMADVIQLY = int.Parse(cmbCuoiNguon.Value + "");
                //cnGiaoNhan.MoTa = txtmoTa.Text;
                //cnGiaoNhan.DiemCuoiNguon = int.Parse(session.User.ma_dviqly);
                //cnGiaoNhan.DiemDauNguon = int.Parse(cmbCuoiNguon.Value + "");
                //if (CkHoatDong.Checked)
                //    cnGiaoNhan.HoatDong = 1;
                //else
                //    cnGiaoNhan.HoatDong = 0;
                //db.DM_ChiNhanhs.InsertOnSubmit(cnGiaoNhan);
                //db.SubmitChanges();
                //}
            }
            pcAddRoles.ShowOnPageLoad = false;
            _DataBind();
        }