Exemplo n.º 1
0
 // Methods
 public static void SetCaption(string caption)
 {
     if (_waitFrm != null)
     {
         _waitFrm.SetCaption(caption);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 显示提示信息
 /// </summary>
 /// <param name="caption">提示信息</param>
 /// <param name="title">标题</param>
 public static void Show(string caption, string title)
 {
     if (_WaitFrm == null || _WaitFrm.IsDisposed)
     {
         _WaitFrm = new WaitDialogForm(caption, title);
     }
     else
     {
         _WaitFrm.SetCaption(caption);
         _WaitFrm.Show();
     }
 }
Exemplo n.º 3
0
        private void btImport_Click_1(object sender, EventArgs e)
        {
            //导入
            if (checkedListBox1.SelectedItem == null)
            {
                return;
            }
            IEnumerator ie = null;

            switch (checkedListBox1.SelectedItem.ToString())
            {
            case "母线":
                ie = importMX();
                break;

            case "线路":
                ie = importXL();
                break;

            case "两绕组变压器":
                ie = importBYQ2();
                break;

            case "三绕组变压器":
                ie = importBYQ3();
                break;

            case "发电机":
                ie = importFDJ();
                break;

            case "负荷":
                ie = importFH();
                break;

            case "并联电容器":
                ie = importBLDR();
                break;
            }
            if (gridControl1.DataSource != null)
            {
                ncount   = (gridControl1.DataSource as DataTable).Rows.Count;
                ncurrent = 0;
                if (ie != null)
                {
                    WaitDialogForm msgbox = new WaitDialogForm("", "导入数据,请稍候。。。");
                    msgbox.Show();

                    while (ie.MoveNext())
                    {
                        msgbox.SetCaption(string.Format("已完成{0}/{1}", ncurrent, ncount));
                    }
                    Thread.Sleep(1000);
                    msgbox.Close();
                }
            }
        }
Exemplo n.º 4
0
        private void Login(string userName, string Password = null)
        {
            WaitDialogForm wfd      = new WaitDialogForm("", "正在登录...");
            string         sqlLogin = Password != null?string.Format("select * from USER_TABLE where USERNAME = '******' and PASSWORD = '******'", userName, Password) : string.Format("select * from USER_TABLE where USERNAME = '******'", userName);

            DataTable oDtLogin = SqliteHelper.GetData(sqlLogin);

            if (oDtLogin.Rows.Count == 1)
            {
                GlobalEnvironment.GlobalUser.UserId   = oDtLogin.Rows[0]["USERID"].ToString();
                GlobalEnvironment.GlobalUser.UserName = oDtLogin.Rows[0]["USERNAME"].ToString();
                //获取所属组信息
                wfd.SetCaption("获取所属组信息...");
                string    sqlGroup = string.Format("select * from GROUP_TABLE where USERS like '%{0}%'", GlobalEnvironment.GlobalUser.UserId);
                DataTable oDtGroup = SqliteHelper.GetData(sqlGroup);
                if (oDtGroup.Rows.Count == 1)
                {
                    GlobalEnvironment.GlobalUser.GroupName = oDtGroup.Rows[0]["GROUPNAME"].ToString();
                }
                //获取上下级信息
                wfd.SetCaption("获取上下级信息...");
                string    sqlUpDown = string.Format("select * from RELUSER_TABLE where USERID = '{0}'", GlobalEnvironment.GlobalUser.UserId);
                DataTable oDtUpDown = SqliteHelper.GetData(sqlUpDown);
                if (oDtUpDown.Rows.Count == 1)
                {
                    string downUserId = oDtUpDown.Rows[0]["DNUSER"].ToString();
                    if (!string.IsNullOrEmpty(downUserId))
                    {
                        GlobalEnvironment.GlobalUser.DownUserId = downUserId.Substring(0, downUserId.Length - 1).Split(',').ToList();
                    }
                }
                wfd.Close();
                this.Visible      = false;
                this.DialogResult = DialogResult.OK;
                //FormMain fm = new FormMain();
                //fm.Show();
            }
            else
            {
                XtraMessageBox.Show("用户名或者密码不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtUserName.Focus();
            }
        }
Exemplo n.º 5
0
        public DataTable GetSBtable(string bdzid)
        {
            string sql = "where svguid='" + bdzid + "' and projectid='" + Itop.Client.MIS.ProgUID + "' and Type='01' ORDER BY Number";

            if (string.IsNullOrEmpty(bdzid))
            {
                sql      = "where  projectid='" + Itop.Client.MIS.ProgUID + "' and Type='01' ORDER BY Number";
                showdeep = false;
            }
            IList <PSPDEV> list = UCDeviceBase.DataService.GetList <PSPDEV>("SelectPSPDEVByCondition", sql);

            if (list.Count > 0)
            {
                msgbox.Show();
                int n = 0;
                try {
                    string strmx = "";
                    foreach (PSPDEV dev in list)
                    {
                        n++;
                        strmx = string.Format("({0}){1}__", n, dev.Name);
                        addrow(dev.SUID, dev.SUID, "root", dev.Type, dev.Number, dev.Name, dev.RateVolt);
                        msgbox.SetCaption(strmx + "线路");
                        initxl(dev.SUID, dev.Name, 0);
                        msgbox.SetCaption(strmx + "负荷");
                        initfh(dev.SUID, dev.Name);
                        msgbox.SetCaption(strmx + "变压器2");
                        initbyq2(dev.SUID, dev.Name);
                        msgbox.SetCaption(strmx + "变压器3");
                        initbyq3(dev.SUID, dev.Name);
                        //if (string.IsNullOrEmpty(bdzid)) break;
                    }
                } catch { }
                msgbox.Hide();
            }
            else if (pdev != null)
            {
                if (pdev.Type == "01")
                {
                    msgbox.Show();
                    initxl(pdev.SUID, pdev.Name, 0);
                    initfh(pdev.SUID, pdev.Name);
                    initbyq2(pdev.SUID, pdev.Name);
                    initbyq3(pdev.SUID, pdev.Name);
                    msgbox.Hide();
                }
                else if (pdev.Type == "05")
                {
                }
            }
            return(sbTable);
        }
Exemplo n.º 6
0
        private void ReCount()
        {
            WaitDialogForm wait = new WaitDialogForm("", "正在更新数据,请稍后...");
            int            m    = 0;

            foreach (TreeListNode node in treeList1.Nodes)
            {
                m++;
                IList <Ps_Forecast_Math> relist = new List <Ps_Forecast_Math>();
                double qzvalue = 0;
                foreach (TreeListNode cnode in node.Nodes)
                {
                    DataRow          row    = (cnode.TreeList.GetDataRecordByNode(cnode) as DataRowView).Row;
                    Ps_Forecast_Math v      = DataConverter.RowToObject <Ps_Forecast_Math>(row);
                    double           mm     = v.y1990;
                    string           select = v.Col2;
                    if (select == "1")
                    {
                        qzvalue += mm;
                        relist.Add(v);
                    }
                }
                //wait.SetCaption(m * 100 / treeList1.Nodes.Count + "%");
                node.SetValue("y1990", qzvalue);
                for (int i = forecastReport.StartYear; i <= forecastReport.YcEndYear; i++)
                {
                    int persent = ((m - 1) * (forecastReport.YcEndYear - forecastReport.StartYear + 1) + i - forecastReport.StartYear) * 100 / (treeList1.Nodes.Count * (forecastReport.YcEndYear - forecastReport.StartYear + 1));
                    wait.SetCaption(persent + "%");
                    double sum = 0;
                    foreach (Ps_Forecast_Math pfm in relist)
                    {
                        double mm = pfm.y1990;

                        sum += double.Parse(pfm.GetType().GetProperty("y" + i).GetValue(pfm, null).ToString()) * mm;
                    }
                    commonhelp.ResetValue(node["ID"].ToString(), "y" + i);
                    node.SetValue("y" + i, sum);
                }
            }
            RefreshChart();
            wait.Close();
        }
Exemplo n.º 7
0
        ///<summary>
        ///将控件添加到标签页中
        ///</summary>
        ///<param name="PageName">窗体名</param>
        ///<param name="ctrl">添加的From/CefSharp.WinForms.ChromiumWebBrowser webComhtml = null</param>
        private void AddControlToPage(string PageName, Form frm = null, XtraTabControl xtraTabControl = null)
        {
            WaitDialogForm waitFrm = new WaitDialogForm("x x", "xxx");

            try
            {
                foreach (XtraTabPage page in xtraTabControl.TabPages)
                {
                    if (page.Text == PageName)
                    {
                        xtraTabControl.SelectedTabPage = page;//显示该页面
                        return;
                    }
                }
                XtraTabPage xpage = new XtraTabPage();
                xpage.Name = PageName;
                xpage.Text = PageName;
                if (frm != null)
                {
                    //frm.MdiParent = this;
                    frm.Visible         = true;
                    frm.Dock            = DockStyle.Fill;
                    frm.FormBorderStyle = FormBorderStyle.None;
                    frm.TopLevel        = false;
                    xpage.Controls.Add(frm);//添加要增加的页面
                }
                //if (webComhtml != null) {
                //    xpage.Controls.Add(webComhtml);//添加要增加的页面
                //}
                xtraTabControl.TabPages.Add(xpage);
                xtraTabControl.SelectedTabPage = xpage;
            }
            catch (Exception ex)
            {
                waitFrm.Refresh();
                waitFrm.SetCaption($"加载异常{ex.ToString()}");
                XtraMessageBox.Show(ex.ToString());
            } finally {
                waitFrm.Close();
            }
        }
        private void btnImportCode_Click(object sender, EventArgs e)
        {
            WaitDialogForm wait = null;

            try
            {

                OpenFileDialog oP = new OpenFileDialog();
                oP.InitialDirectory = "My Documents://";
                oP.Filter = HelpExcel.FILTER_FILE_OPEN;
                oP.Title = HelpApplication.getTitleForm("Chọn bảng giá kế toán");
                if (oP.ShowDialog() == DialogResult.Cancel) return;
                System.Windows.Forms.Application.DoEvents();
                string filenamepath = oP.FileName;
                wait = new WaitDialogForm("Đang xử lý..", "Import code chương trình từ excel!", new Size(250, 50));

                string tempFilePath = AppUtil.GetTempFile(Path.GetExtension(filenamepath));
                File.Copy(filenamepath, tempFilePath, true);
                FileInfo inf = new FileInfo(tempFilePath);

                if (inf.IsReadOnly)
                {
                    inf.IsReadOnly = false;
                }

                wait.SetCaption("Đang kết nối tập tin excel...");
                XlsFileConnection conn = new XlsFileConnection(tempFilePath);
                if (ValidateConnection(conn, filenamepath, wait) == false)
                {
                    if (wait != null) wait.Close();
                    return;
                }
                DataSet ds = new DataSet();

                ds = conn.LoadDataSet(CHUONG_TRINH.TABLE_NAME, null);
                if (ds == null || ds.Tables.Count == 0)
                {
                    wait.Close();
                    HelpMsgBox.ShowNotificationMessage("Tập tin excel có cấu trúc không đúng mẫu, vui lòng kiểm tra lại");
                    return;
                }
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)//Loại bỏ dòng rỗng
                {
                    ds.Tables[0].Rows.RemoveAt(0);
                }
                conn.Close();

                DataTable dt = ds.Tables[0];
                dt.Columns.Add(CHUONG_TRINH.CT_ID, typeof(Int64));
                dt.Columns.Add("CODE_CT_OLD");
                DataRow r = null;
                string sql = "select ct.*,ct.code_ct code_ct_old from "+ CHUONG_TRINH.TABLE_NAME + " ct where ct." + CHUONG_TRINH.MA_CT + "='{0}'";

                DataSet dsSource = HelpDB.getDBService().LoadDataSet(string.Format(sql, "-1"),CHUONG_TRINH.TABLE_NAME);
                DataTable dtSource = dsSource.Tables[0];
                DataSet dsTemp = null;
                string error = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    r = dt.Rows[i];
                    dsTemp = HelpDB.getDBService().LoadDataSet(string.Format(sql, r[CHUONG_TRINH.MA_CT]));
                    if (dsTemp != null && dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
                    {
                        dsTemp.Tables[0].Rows[0][CHUONG_TRINH.CODE_CT] = r[CHUONG_TRINH.CODE_CT];
                        dtSource.ImportRow(dsTemp.Tables[0].Rows[0]);
                    }
                    else
                    {
                        error += "";
                    }
                }

                gridControlImport.DataSource = dtSource;
               ;

            }
            catch (Exception ex)
            {
                if (wait != null) wait.Close();
                HelpMsgBox.ShowNotificationMessage("Tập tin excel có cấu trúc không đúng mẫu, vui lòng kiểm tra lại.");
                PLException.AddException(ex);
                return;
            }
            finally
            {
                if (wait != null) wait.Close();
            }
        }
Exemplo n.º 9
0
        private void btImport_Click_1(object sender, EventArgs e)
        {
            //����
            if (checkedListBox1.SelectedItem == null) return;
            IEnumerator ie = null;
            switch (checkedListBox1.SelectedItem.ToString()) {
                case "ĸ��":
                    ie = importMX();
                    break;
                case "��·":
                    ie = importXL();
                    break;
                case "�������ѹ��":
                    ie = importBYQ2();
                    break;
                case "�������ѹ��":
                    ie = importBYQ3();
                    break;
                case "�����":
                    ie = importFDJ();
                    break;
                case "����":
                    ie = importFH();
                    break;
                case "����������":
                    ie = importBLDR();
                    break;
            }
            if (gridControl1.DataSource!=null)
            {
                ncount = (gridControl1.DataSource as DataTable).Rows.Count;
                ncurrent = 0;
                if (ie != null)
                {
                    WaitDialogForm msgbox = new WaitDialogForm("", "�������ݣ����Ժ򡣡���");
                    msgbox.Show();

                    while (ie.MoveNext())
                    {
                        msgbox.SetCaption(string.Format("�����{0}/{1}", ncurrent, ncount));
                    }
                    Thread.Sleep(1000);
                    msgbox.Close();
                }
            }
        }
Exemplo n.º 10
0
        public DataSet GetImportDataSet()
        {
            WaitDialogForm wait = null;

            try
            {

                OpenFileDialog oP = new OpenFileDialog();
                oP.InitialDirectory = "My Documents://";
                oP.Filter = HelpExcel.FILTER_FILE_OPEN;
                oP.Title = HelpApplication.getTitleForm("Import dữ liệu từ tập tin excel");
                if (oP.ShowDialog() == DialogResult.Cancel) return null;
                System.Windows.Forms.Application.DoEvents();
                string filenamepath = oP.FileName;
                wait = new WaitDialogForm("Đang xử lý..", "Import dữ liệu từ excel!", new Size(250, 50));

                string tempFilePath = AppUtil.GetTempFile(Path.GetExtension(filenamepath));
                File.Copy(filenamepath, tempFilePath, true);
                FileInfo inf = new FileInfo(tempFilePath);

                if (inf.IsReadOnly)
                {
                    inf.IsReadOnly = false;
                }

                wait.SetCaption("Đang kết nối tập tin excel...");
                XlsFileConnection conn = new XlsFileConnection(tempFilePath);
                if (ValidateConnection(conn, filenamepath, wait) == false)
                {
                    if (wait != null) wait.Close();
                    return null;
                }
                DataSet ds = new DataSet();

                ds = conn.LoadDataSet(BANG_GIA_BUDGET_CT.TABLE_NAME, null);
                if (ds == null)
                {
                    wait.Close();
                    HelpMsgBox.ShowNotificationMessage("Tập tin excel có cấu trúc không đúng mẫu, vui lòng kiểm tra lại");
                    return null;
                }
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)//Loại bỏ dòng rỗng
                {
                    ds.Tables[0].Rows.RemoveAt(0);
                }
                conn.Close();

                System.Windows.Forms.Application.DoEvents();

                return ds;

            }
            catch (Exception ex)
            {
                if (wait != null) wait.Close();
                HelpMsgBox.ShowNotificationMessage("Tập tin excel có cấu trúc không đúng mẫu, vui lòng kiểm tra lại.");
                PLException.AddException(ex);
                return null;
            }
            finally
            {
                if (wait != null) wait.Close();
            }
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="error"></param>
        /// <param name="strFileName"></param>
        /// <param name="dsSource"></param>
        /// <param name="pwd"></param>
        /// <param name="rowIndex"></param>
        /// <param name="wait"></param>
        /// <param name="isAppend"></param>
        /// <param name="dateFormat"></param>
        public static void DataTableToExcel(ref string error, string strFileName, DataSet dsSource, string pwd, ref int rowIndex, WaitDialogForm wait = null, bool isAppend = false, string dateFormat = "yyyy-MM-dd")
        {
            try {
                error = string.Empty;
                FileStream   fs       = null;
                XSSFWorkbook workbook = null;
                if (!isAppend)
                {
                    fs       = new FileStream(strFileName, FileMode.Create, FileAccess.Write);
                    workbook = new XSSFWorkbook();
                }
                else
                {
                    fs       = new FileStream(strFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    workbook = new XSSFWorkbook(fs);//将文件读到内存,在内存中操作excel
                }
                fs.Close();

                #region 右击文件 属性信息
                {
                    DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
                    dsi.Company = "Xw";
                    //     workbook.DocumentSummaryInformation = dsi;

                    SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
                    si.Author          = "xw"; //填加xls文件作者信息
                    si.ApplicationName = "xw"; //填加xls文件创建程序信息
                    si.LastAuthor      = "xw"; //填加xls文件最后保存者信息
                    si.Comments        = "xw"; //填加xls文件作者信息
                    si.Title           = "xw"; //填加xls文件标题信息
                    si.Subject         = "xw"; //填加文件主题信息
                    si.CreateDateTime  = System.DateTime.Now;
                    //    workbook.SummaryInformation = si;
                }
                #endregion
                XSSFCellStyle  dateStyle = (XSSFCellStyle)workbook.CreateCellStyle();
                XSSFDataFormat format    = (XSSFDataFormat)workbook.CreateDataFormat();
                dateStyle.DataFormat = format.GetFormat(dateFormat);
                XSSFCellStyle headStyle = (XSSFCellStyle)workbook.CreateCellStyle();
                XSSFCellStyle rowStyle  = (XSSFCellStyle)workbook.CreateCellStyle();
                XSSFFont      fontRow   = (XSSFFont)workbook.CreateFont();
                XSSFFont      font      = (XSSFFont)workbook.CreateFont();
                font.FontHeightInPoints = 9;
                font.FontName           = "微软雅黑";
                //font.Boldweight = 700;
                headStyle.SetFont(font);

                fontRow.FontHeightInPoints = 9;
                fontRow.FontName           = "微软雅黑";
                rowStyle.SetFont(fontRow);

                for (int k = 0; k < dsSource.Tables.Count; k++)
                {
                    var dtSource = dsSource.Tables[k];

                    XSSFSheet sheet = null;
                    if (!isAppend)
                    {
                        rowIndex = 0;
                        sheet    = (XSSFSheet)workbook.CreateSheet();
                        if (!string.IsNullOrEmpty(pwd))
                        {
                            sheet.ProtectSheet(pwd);
                        }
                        workbook.SetSheetName(k, dtSource.TableName);
                    }
                    else
                    {
                        sheet = (XSSFSheet)workbook.GetSheet(dtSource.TableName);
                        if (sheet == null)
                        {
                            isAppend = false;
                            rowIndex = 0;
                            sheet    = (XSSFSheet)workbook.CreateSheet();
                            if (!string.IsNullOrEmpty(pwd))
                            {
                                sheet.ProtectSheet(pwd);
                            }
                            workbook.SetSheetName(k, dtSource.TableName);
                        }
                    }

                    if (wait != null)
                    {
                        wait.SetCaption(string.Format("正在创建第 {0} / {1} Excel的Sheet中", (k + 1), dsSource.Tables.Count));//"(" + (k + 1) + " /" + dsSource.Tables.Count + ")Excel的Sheet中...");
                    }
                    //取得列宽
                    int[] arrColWidth = new int[dtSource.Columns.Count];
                    foreach (DataColumn item in dtSource.Columns)
                    {
                        arrColWidth[item.Ordinal] = Encoding.GetEncoding(936).GetBytes(item.ColumnName.ToString()).Length;
                    }
                    for (int i = 0; i < dtSource.Rows.Count; i++)
                    {
                        for (int j = 0; j < dtSource.Columns.Count; j++)
                        {
                            int intTemp = Encoding.GetEncoding(936).GetBytes(dtSource.Rows[i][j].ToString()).Length;
                            if (intTemp > arrColWidth[j])
                            {
                                arrColWidth[j] = intTemp;
                            }
                        }
                    }

                    foreach (DataRow row in dtSource.Rows)
                    {
                        #region 新建表,填充表头,填充列头,样式
                        if (!isAppend)
                        {
                            //if (rowIndex != 0) {
                            //sheet = (XSSFSheet)workbook.CreateSheet();
                            //if (!string.IsNullOrEmpty(pwd)) {
                            //    sheet.ProtectSheet(pwd);
                            //}
                            //}
                            #region 表头及样式
                            //    if (!string.IsNullOrEmpty(strHeaderText)) {
                            //        rowIndex++;
                            //        XSSFRow headerRow = (XSSFRow)sheet.CreateRow(rowIndex);
                            //        headerRow.HeightInPoints = 25;
                            //        headerRow.CreateCell(0).SetCellValue(strHeaderText);

                            //        XSSFCellStyle headStyle = (XSSFCellStyle)workbook.CreateCellStyle();
                            //        //  headStyle.Alignment = CellHorizontalAlignment.CENTER;
                            //        XSSFFont font = (XSSFFont)workbook.CreateFont();
                            //        font.FontHeightInPoints = 20;
                            //        font.Boldweight = 700;
                            //        headStyle.SetFont(font);
                            //        headerRow.GetCell(0).CellStyle = headStyle;
                            //        // sheet.AddMergedRegion(new Region(0, 0, 0, dtSource.Columns.Count - 1));
                            //        //headerRow.Dispose();
                            //    }
                            #endregion
                            #region 列头及样式
                            XSSFRow headerRow = (XSSFRow)sheet.CreateRow(0);
                            foreach (DataColumn column in dtSource.Columns)
                            {
                                headerRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
                                headerRow.GetCell(column.Ordinal).CellStyle = headStyle;
                                //headerRow.GetCell(column.Ordinal).CellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
                                //headerRow.GetCell(column.Ordinal).CellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
                                //headerRow.GetCell(column.Ordinal).CellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
                                //headerRow.GetCell(column.Ordinal).CellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
                                //设置列宽
                                // sheet.SetColumnWidth(column.Ordinal, (arrColWidth[column.Ordinal] + 1) * 256);
                            }

                            #endregion
                            isAppend = true;
                            rowIndex = 1;
                        }
                        #endregion

                        if (wait != null)
                        {
                            wait.SetCaption(string.Format("正在将数据写入Excel第 {0} / {1} 行中...", rowIndex, dtSource.Rows.Count));//"正在写入第(" + (k + 1) + "/" + dsSource.Tables.Count + "个ExcelSheet表格中的第 " + rowIndex + "/" + dtSource.Rows.Count + " 行数据...");
                        }
                        #region 填充内容
                        XSSFRow dataRow = (XSSFRow)sheet.CreateRow(rowIndex);
                        foreach (DataColumn column in dtSource.Columns)
                        {
                            XSSFCell newCell = (XSSFCell)dataRow.CreateCell(column.Ordinal);
                            newCell.CellStyle = rowStyle;

                            //newCell.CellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
                            //newCell.CellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
                            //newCell.CellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
                            //newCell.CellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
                            var obj = row[column];
                            if (obj == null)
                            {
                                continue;
                            }

                            string drValue = row[column].ToString();

                            switch (column.DataType.ToString())
                            {
                            case "System.String":    //字符串类型
                                double tempVal = 0;
                                var    isflg   = double.TryParse(drValue, out tempVal);
                                if (isflg)
                                {
                                    newCell.SetCellValue(tempVal);
                                    newCell.SetCellType(CellType.Numeric);
                                }
                                else
                                {
                                    newCell.SetCellValue(drValue);
                                    newCell.SetCellType(CellType.String);
                                }
                                break;

                            case "System.DateTime":    //日期类型
                                System.DateTime dateV;
                                isflg = System.DateTime.TryParse(drValue, out dateV);
                                if (isflg)
                                {
                                    newCell.SetCellValue(drValue);
                                }
                                else
                                {
                                    newCell.SetCellValue(string.Empty);
                                }

                                break;

                            case "System.Boolean":    //布尔型
                                bool boolV = false;
                                bool.TryParse(drValue, out boolV);
                                newCell.SetCellValue(boolV);
                                break;

                            case "System.Int16":    //整型
                            case "System.Int32":
                            case "System.Int64":
                            case "System.UInt16":    //整型
                            case "System.UInt32":
                            case "System.UInt64":
                                int intV = 0;
                                isflg = int.TryParse(drValue, out intV);
                                if (isflg)
                                {
                                    newCell.SetCellValue(intV);
                                    newCell.SetCellType(CellType.Numeric);
                                }
                                break;

                            case "System.Single":    //浮点型
                            case "System.Decimal":   //浮点型
                            case "System.Double":
                                double doubV = 0;
                                isflg = double.TryParse(drValue, out doubV);
                                if (isflg)
                                {
                                    newCell.SetCellValue(doubV);
                                    newCell.SetCellType(CellType.Numeric);
                                }
                                break;

                            case "System.DBNull":    //空值处理
                                newCell.SetCellValue("");
                                newCell.SetCellType(CellType.String);
                                break;

                            default:
                                tempVal = 0;
                                isflg   = double.TryParse(drValue, out tempVal);
                                if (isflg)
                                {
                                    newCell.SetCellValue(tempVal);
                                    newCell.SetCellType(CellType.Numeric);
                                }
                                else
                                {
                                    newCell.SetCellValue(drValue);
                                    newCell.SetCellType(CellType.String);
                                }
                                break;
                            }
                        }
                        #endregion

                        rowIndex++;
                    }
                    if (sheet != null)
                    {
                        sheet.ForceFormulaRecalculation = true;
                    }
                }

                //将内存数据写到文件
                using (FileStream fs1 = File.OpenWrite(strFileName)) {
                    workbook.Write(fs1);
                    workbook.Close();
                }
            } catch (Exception ex) {
                error = $"导出数据出错{ex.Message}";
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void LoadData()
        {
            float percent     = 0;
            float SheetCount1 = SheetCount;

            this.Text = " 铜陵市各电压等级配电网规划建设工程投资估算 ";
            InitTitle();
            AddSheet();
            this.barEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            percent = (1 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_1.SetSheet10_1Title(fpSpread1_Sheet1, Title[0]);
            percent = (2 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_1_1.SetSheet10_1_1Title(fpSpread1_Sheet2, Title[1]);
            percent = (3 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_2.SetSheet10_2Title(fpSpread1_Sheet3, Title[2]);
            percent = (4 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_3.SetSheet10_3Title(fpSpread1_Sheet4, Title[3]);
            percent = (5 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_3_1.SetSheet10_3_1Title(fpSpread1_Sheet5, Title[4]);
            percent = (6 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_4.SetSheet10_4Title(fpSpread1, fpSpread1_Sheet6, Title[5]);
            percent = (7 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_4_1.SetSheet10_4_1Title(fpSpread1, fpSpread1_Sheet7, Title[6]);
            percent = (8 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_5.SetSheet10_5Title(fpSpread1, fpSpread1_Sheet8, Title[7]);
            percent = (9 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_6.SetSheet10_6Title(fpSpread1_Sheet9, Title[8]);
            percent = (10 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_7.SetSheet10_7Title(fpSpread1_Sheet10, Title[9]);
            percent = (11 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_8.SetSheet10_8Title(fpSpread1_Sheet11, Title[10]);
            percent = (12 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_9.SetSheet10_9Title(fpSpread1_Sheet12, Title[11]);
            percent = (13 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_10.SetSheet10_10Title(fpSpread1_Sheet13, Title[12], false);//手写
            this.barEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
            S10_11.AddBarEditItems(this.barEditItem1, this.barEditItem2, this);
            SheetNClear(fpSpread1.Sheets[13]);
            percent = (14 / SheetCount1);
            wait1.SetCaption("正在加载数据..." + percent.ToString("P"));
            S10_11.SetSheet10_11Title(fpSpread1_Sheet14, Title[13]);

            this.AddCellChanged();            //响应单元格改变
            this.barEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            PF.Sheet_AutoLineFeed(fpSpread1); //设置整个工作簿换行
        }
Exemplo n.º 13
0
        /// <summary>
        /// 备份一个台区的杆塔经纬度
        /// </summary>
        /// <param name="lineCode"></param>
        internal static void RestoreGTLatLngTQ(string tqCode) {
            WaitDialogForm waitdlg = new WaitDialogForm("", "恢复台区经纬度");
            IList<PS_xl> listxl = Client.ClientHelper.PlatformSqlMap.GetList<PS_xl>(string.Format("where left(linecode,{0})='{1}' and linevol='0.4'", tqCode.Length, tqCode));
            foreach (PS_xl item in listxl) {
                waitdlg.SetCaption(item.LineName);

                RestoreGTLatLng(item.LineCode);

            }

            waitdlg.Close();
        }
        //按三产单耗计算
        private void CalcPer()
        {
            //生产总值(亿元)
            //用电量(亿kWh)
            //单耗(kW/万元)
            //计算数据
            DataRow gdprow = gdprows[0];
            DataRow gdprow01 = gdprows01[0];
            DataRow gdprow02 = gdprows02[0];
            DataRow gdprow03 = gdprows03[0];

            DataRow dlrow = dlrows[0];
            DataRow dlrow01 = dlrows01[0];
            DataRow dlrow02 = dlrows02[0];
            DataRow dlrow03 = dlrows03[0];
            DataRow dlrow04 = dlrows04[0];

            DataRow dhrow = dhrows[0];
            DataRow dhrow01 = dhrows01[0];
            DataRow dhrow02 = dhrows02[0];
            DataRow dhrow03 = dhrows03[0];

            WaitDialogForm wait = new WaitDialogForm("","正在重新计算,请稍后...");
            treeList1.BeginInit();
            int allsum = forecastReport.YcEndYear - forecastReport.StartYear;

            for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
            {
                wait.SetCaption ((i - forecastReport.StartYear) * 100 / allsum + "%");
                //总单耗
                double gdp = double.Parse(gdprow["y" + i].ToString());
                double dl = double.Parse(dlrow["y" + i].ToString());
                double dh = double.Parse(dhrow["y" + i].ToString());
                if (gdp != 0)
                {
                    dh = dl * unitdata / gdp;
                }
                else
                {
                    dh = 0;
                }
                dhrow["y" + i] = Math.Round(dh, 4);
                //commonhelp.ResetValue(dhrow["ID"].ToString(), "y" + i);
                //分单耗01
                double gdp01 = double.Parse(gdprow01["y" + i].ToString());
                double dl01 = double.Parse(dlrow01["y" + i].ToString());
                double dh01 = double.Parse(dhrow01["y" + i].ToString());
                if (gdp01 != 0)
                {
                    dh01 = dl01 * unitdata / gdp01;
                }
                else
                {
                    dh01 = 0;
                }
                dhrow01["y" + i] = Math.Round(dh01, 4);
                //commonhelp.ResetValue(dhrow01["ID"].ToString(), "y" + i);

                //分单耗02

                double gdp02 = double.Parse(gdprow02["y" + i].ToString());
                double dl02 = double.Parse(dlrow02["y" + i].ToString());
                double dh02 = double.Parse(dhrow02["y" + i].ToString());
                if (gdp02 != 0)
                {
                    dh02 = dl02 * unitdata / gdp02;
                }
                else
                {
                    dh02 = 0;
                }
                dhrow02["y" + i] = Math.Round(dh02, 4);
                //commonhelp.ResetValue(dhrow02["ID"].ToString(), "y" + i);
                //分单耗03

                double gdp03 = double.Parse(gdprow03["y" + i].ToString());
                double dl03 = double.Parse(dlrow03["y" + i].ToString());
                double dh03 = double.Parse(dhrow03["y" + i].ToString());
                if (gdp03 != 0)
                {
                    dh03 = dl03 * unitdata / gdp03;
                }
                else
                {
                    dh03 = 0;
                }
                dhrow03["y" + i] = Math.Round(dh03, 4);
                //commonhelp.ResetValue(dhrow03["ID"].ToString(), "y" + i);
            }
            Ps_Forecast_Math dhpfm = DataConverter.RowToObject<Ps_Forecast_Math>(dhrow);
            Ps_Forecast_Math dhpfm01 = DataConverter.RowToObject<Ps_Forecast_Math>(dhrow01);
            Ps_Forecast_Math dhpfm02 = DataConverter.RowToObject<Ps_Forecast_Math>(dhrow02);
            Ps_Forecast_Math dhpfm03 = DataConverter.RowToObject<Ps_Forecast_Math>(dhrow03);

            Common.Services.BaseService.Update<Ps_Forecast_Math>(dhpfm);
            Common.Services.BaseService.Update<Ps_Forecast_Math>(dhpfm01);
            Common.Services.BaseService.Update<Ps_Forecast_Math>(dhpfm02);
            Common.Services.BaseService.Update<Ps_Forecast_Math>(dhpfm03);

            for (int i = forecastReport.YcStartYear; i <= forecastReport.YcEndYear; i++)
            {
                wait.SetCaption((i - forecastReport.StartYear) * 100 / allsum + "%");
                double gdp = double.Parse(gdprow["y" + i].ToString());
                double dl = double.Parse(dlrow["y" + i].ToString());
                double dh = double.Parse(dhrow["y" + i].ToString());
                dl = dh * gdp / unitdata;
                dlrow["y" + i] = Math.Round(dl, 4);
                //commonhelp.ResetValue(dlrow["ID"].ToString(), "y" + i);
                //分电量01
                double gdp01 = double.Parse(gdprow01["y" + i].ToString());
                double dl01 = double.Parse(dlrow01["y" + i].ToString());
                double dh01 = double.Parse(dhrow01["y" + i].ToString());

                dl01 = dh01 * gdp01 / unitdata;
                dlrow01["y" + i] = Math.Round(dl01, 4);
                //commonhelp.ResetValue(dlrow01["ID"].ToString(), "y" + i);

                //分电量02

                double gdp02 = double.Parse(gdprow02["y" + i].ToString());
                double dl02 = double.Parse(dlrow02["y" + i].ToString());
                double dh02 = double.Parse(dhrow02["y" + i].ToString());

                dl02 = dh02 * gdp02 / unitdata;
                dlrow02["y" + i] = Math.Round(dl02, 4);
                //commonhelp.ResetValue(dlrow02["ID"].ToString(), "y" + i);

                //分电量03
                double gdp03 = double.Parse(gdprow03["y" + i].ToString());
                double dl03 = double.Parse(dlrow03["y" + i].ToString());
                double dh03 = double.Parse(dhrow03["y" + i].ToString());

                dl03 = dh03 * gdp03 / unitdata;
                dlrow03["y" + i] = Math.Round(dl03, 4);
                //commonhelp.ResetValue(dlrow03["ID"].ToString(), "y" + i);

                double dl04 = double.Parse(dlrow04["y" + i].ToString());

                dlrow["y" + i] = Math.Round((dl01 + dl02 + dl03 + dl04), 4);
                //commonhelp.ResetValue(dlrow["ID"].ToString(), "y" + i);

                dl = double.Parse(dlrow["y" + i].ToString());

                if (gdp != 0)
                {
                    dh = dl * unitdata / gdp;
                }
                else
                {
                    dh = 0;
                }

                dhrow["y" + i] = Math.Round(dh, 4);
                //commonhelp.ResetValue(dhrow["ID"].ToString(), "y" + i);

            }
            dlrow["Col4"] = "yes";

             dhpfm = DataConverter.RowToObject<Ps_Forecast_Math>(dhrow);
            Ps_Forecast_Math dlpfm = DataConverter.RowToObject<Ps_Forecast_Math>(dlrow);
            Ps_Forecast_Math dlpfm01 = DataConverter.RowToObject<Ps_Forecast_Math>(dlrow01);
            Ps_Forecast_Math dlpfm02 = DataConverter.RowToObject<Ps_Forecast_Math>(dlrow02);
            Ps_Forecast_Math dlpfm03 = DataConverter.RowToObject<Ps_Forecast_Math>(dlrow03);

            Common.Services.BaseService.Update<Ps_Forecast_Math>(dhpfm);
            Common.Services.BaseService.Update<Ps_Forecast_Math>(dlpfm);
            Common.Services.BaseService.Update<Ps_Forecast_Math>(dlpfm01);
            Common.Services.BaseService.Update<Ps_Forecast_Math>(dlpfm02);
            Common.Services.BaseService.Update<Ps_Forecast_Math>(dlpfm03);

            treeList1.EndInit();
            wait.Close();
        }
Exemplo n.º 15
0
        public void FileReadDL(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf, string con, StringBuilder dianLiuResult)
        {
            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
            {
            }
            else
            {
                return;
            }
            FileStream dianLiu = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt", FileMode.Open);
            StreamReader readLineDL = new StreamReader(dianLiu, System.Text.Encoding.Default);
            string strLineDL;
            string[] arrayDL;
            char[] charSplitDL = new char[] { ' ' };
            strLineDL = readLineDL.ReadLine();
            int j = 0;
            int linenum = 0;
            while (strLineDL != null)
            {
                arrayDL = strLineDL.Split(charSplitDL, StringSplitOptions.RemoveEmptyEntries);
                int m = 0;
                string[] dev = arrayDL;
                //dev.Initialize();
                //foreach (string str in arrayDL)
                //{
                //    if (str != "")
                //    {
                //        dev[m++] = str;
                //    }
                //}
                if (j == 0)
                {
                    //dianLiuResult.Append( "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n";
                    dianLiuResult.Append(dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
                                 dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "," + dev[14] + "\r\n");
                }
                else
                {
                    if (dev[0] == "����ĸ��")
                    {
                        dianLiuResult.Append("\r\n" + "����ĸ�ߣ�" + dev[1] + "\r\n");
                    }
                    else
                    {
                        PSPDEV CR = new PSPDEV();

                        if (dev[0] != "du")
                        {

                            con = " WHERE Name='" + dev[0] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                        }
                        else
                            con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";

                        CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);

                        dianLiuResult.Append(dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[8] + "," +
                          Convert.ToDouble(dev[9]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[12] + "," + Convert.ToDouble(dev[13]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[14] + "\r\n");
                    }
                    //��Ϊ����·�������ʱ����һ����·�ĵ��������������������·�ĵ������нӵص������͵翹���ĵ��������ֻ���������������

                }

                strLineDL = readLineDL.ReadLine();
                j++;
                linenum++;
                wf.SetCaption(linenum.ToString());
            }
            readLineDL.Close();
        }
Exemplo n.º 16
0
 private void SetNum(int num)
 {
     wf.SetCaption(num.ToString());
 }
Exemplo n.º 17
0
        /// <summary>
        /// 加载数据,表头
        /// </summary>
        private void InitSheetData()
        {
            float SheetCount1 = SheetCount;
            float percent     = 0;

            InitMenu();
            this.barEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            percent = 1 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_1.SetSheet_1Title(this, fpSpread1_Sheet1, strTitle[0], false);//手写

            percent = 2 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_2.SetSheet_2Title(this, fpSpread1_Sheet2, strTitle[1]);
            /*从下面表开始连续5各表有年份下拉菜单*********************************/
            this.barEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
            S_3.AddBarEditItems(this.barEditItem1);
            S_3.strYear = this.barEditItem1.EditValue.ToString();
            percent     = 3 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_3.SetSheet_3Title(this, fpSpread1_Sheet3, strTitle[2]);
            S_4.strYear = this.barEditItem1.EditValue.ToString();
            percent     = 4 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_4.SetSheet_4Title(this, fpSpread1_Sheet4, strTitle[3]);
            S_5.strYear = this.barEditItem1.EditValue.ToString();
            percent     = 5 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_5.SetSheet_5Title(this, fpSpread1_Sheet5, strTitle[4]);
            S_6.strYear = this.barEditItem1.EditValue.ToString();
            percent     = 6 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_6.SetSheet_6Title(this, fpSpread1_Sheet6, strTitle[5]);
            S_7.strYear = this.barEditItem1.EditValue.ToString();
            percent     = 7 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_7.SetSheet_7Title(this, fpSpread1_Sheet7, strTitle[6]);
            ///******************************************************************************************/
            this.barEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            percent = 1 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_8.SetSheet_8Title(this, fpSpread1_Sheet8, strTitle[7], false);//手写
            percent = 9 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_9.SetSheet_9Title(this, fpSpread1_Sheet9, strTitle[8], false);//手写
            percent = 10 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_10.SetSheet_10Title(this, fpSpread1_Sheet10, strTitle[9], false);//手写

            percent = 11 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_11.SetSheet_11Title(this, fpSpread1_Sheet11, strTitle[10]);
            percent = 12 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_12.SetSheet_12Title(this, fpSpread1_Sheet12, strTitle[11], false);//手写

            percent = 13 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_13.SetSheet_13Title(this, fpSpread1_Sheet13, strTitle[12]);
            percent = 14 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_14.SetSheet_14Title(this, fpSpread1_Sheet14, strTitle[13]);
            percent = 15 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_15.SetSheet_15Title(this, fpSpread1_Sheet15, strTitle[14]);
            percent = 16 / SheetCount1;
            wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            S_16.SetSheet_16Title(this, fpSpread1_Sheet16, strTitle[15]);

            AddSheet();
            this.AddCellChanged();
            PF.Sheet_AutoLineFeed(fpSpread1);//设置整个工作簿换行
        }
Exemplo n.º 18
0
        private void ReCount()
        {
            WaitDialogForm wait = new WaitDialogForm("", "正在更新数据,请稍后...");
            int m = 0;
            foreach (TreeListNode node in treeList1.Nodes)
            {
                m++;
                IList<Ps_Forecast_Math> relist = new List<Ps_Forecast_Math>();
                double qzvalue = 0;
                foreach (TreeListNode cnode in node.Nodes)
                {
                    DataRow row = (cnode.TreeList.GetDataRecordByNode(cnode) as DataRowView).Row;
                    Ps_Forecast_Math v = DataConverter.RowToObject<Ps_Forecast_Math>(row);
                    double mm = v.y1990;
                    string select = v.Col2;
                    if (select == "1")
                    {
                        qzvalue += mm;
                        relist.Add(v);
                    }
                }
                //wait.SetCaption(m * 100 / treeList1.Nodes.Count + "%");
                node.SetValue("y1990", qzvalue);
                for (int i = forecastReport.StartYear; i <= forecastReport.YcEndYear; i++)
                {
                    int persent = ((m - 1) * (forecastReport.YcEndYear - forecastReport.StartYear + 1) + i - forecastReport.StartYear) * 100 / (treeList1.Nodes.Count * (forecastReport.YcEndYear - forecastReport.StartYear + 1));
                    wait.SetCaption(persent + "%");
                    double sum = 0;
                    foreach (Ps_Forecast_Math pfm in relist)
                    {
                        double mm = pfm.y1990;

                        sum += double.Parse(pfm.GetType().GetProperty("y" + i).GetValue(pfm, null).ToString()) * mm;

                    }
                    commonhelp.ResetValue(node["ID"].ToString(), "y" + i);
                    node.SetValue("y" + i, sum);
                }

            }
            RefreshChart();
            wait.Close();
        }
Exemplo n.º 19
0
        //更新线路
        private void barButtonItem20_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Hashtable area_key_id = new Hashtable();
            //初始化哈希表
            string areaall = " ProjectID='" + GetProjectID + "'";
            IList<PS_Table_AreaWH> tempPTA = Common.Services.BaseService.GetList<PS_Table_AreaWH>("SelectPS_Table_AreaWHByConn", areaall);

            if (tempPTA.Count != 0)
            {
                for (int i = 0; i < tempPTA.Count; i++)
                {
                    area_key_id.Add(tempPTA[i].ID, tempPTA[i].Title);
                }
            }

            int year = yAnge.StartYear;
            string con = "Col4='line' and ProjectID='" + GetProjectID + "' and ParentID='0'";
            IList list = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", con);
            DataTable dt = Itop.Common.DataConverter.ToDataTable(list, typeof(Ps_Table_BuildPro));

            string con2 = "Col4='line' and ProjectID='" + GetProjectID + "'";
            IList list2 = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", con2);
            DataTable dt2 = Itop.Common.DataConverter.ToDataTable(list2, typeof(Ps_Table_BuildPro));

            WaitDialogForm wait = new WaitDialogForm("", "正在更新线路数据,请稍后...");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string parentid = dt.Rows[i]["ID"].ToString();
                string dy = dt.Rows[i]["FromID"].ToString();

                string connjz = " where ProjectID ='" + GetProjectID + "' and Type='05' and RateVolt=" + dy + " and Cast(Date1 as int)>" + year;
                IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz);
                int mm = 0;

                foreach (PSPDEV psi in listatt)
                {
                    mm++;
                    int perent = (i + 1) * 100 * mm / listatt.Count / dt.Rows.Count;
                    wait.SetCaption(perent + "%");

                    Ps_Table_BuildPro table1 = new Ps_Table_BuildPro();
                    table1.ID += "|" + GetProjectID;
                    table1.Title = psi.Name;
                    table1.ParentID = parentid;
                    table1.ProjectID = GetProjectID;
                    table1.BuildYear = psi.Date1;
                    table1.BuildEd = psi.OperationYear;
                    table1.FromID = dy;
                    table1.Length = psi.LineLength+psi.Length2;

                    //  table1.BefVolumn = frm.AllVol;
                    table1.GetType().GetProperty("y" + psi.Date1).SetValue(table1, table1.Length, null);
                    table1.Col4 = "line";
                    table1.Sort = OperTable.GetBuildProMaxSort() + 1;
                    table1.Col10 = psi.SUID;
                    table1.Col3 = "新建";
                    if (area_key_id[psi.AreaID]!=null)
                    {
                        table1.AreaName = area_key_id[psi.AreaID].ToString();
                    }

                    try
                    {
                        if (DTHave(dt2, psi.SUID))
                        {

                            UPDateOldXl(dt2, psi.SUID, table1);
                        }
                        else
                        {
                            Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table1);
                            dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow()));
                            AddChildVol(table1, true);
                        }

                    }
                    catch (Exception ee)
                    {
                        wait.Close();
                    }

                }
            }
            LoadData1();
            wait.Close();
        }
Exemplo n.º 20
0
        //更新变电站
        private void barButtonItem19_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int year = yAnge.StartYear;
            string con = "Col4='bian' and ProjectID='" + GetProjectID + "' and ParentID='0'";
            IList list = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", con);
            DataTable dt = Itop.Common.DataConverter.ToDataTable(list, typeof(Ps_Table_BuildPro));

            string con2 = "Col4='bian' and ProjectID='" + GetProjectID + "'";
            IList list2 = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", con2);
            DataTable dt2 = Itop.Common.DataConverter.ToDataTable(list2, typeof(Ps_Table_BuildPro));

            WaitDialogForm wait = new WaitDialogForm("", "正在更新变电站数据,请稍后...");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string parentid = dt.Rows[i]["ID"].ToString();
                string dy = dt.Rows[i]["FromID"].ToString();

                string conn1 = " AreaID='" + GetProjectID + "' and L1=" + dy;
                IList<PSP_Substation_Info> listbdz = Common.Services.BaseService.GetList<PSP_Substation_Info>("SelectPSP_Substation_InfoListByWhere", conn1);
                int mm = 0;

                foreach (PSP_Substation_Info psi in listbdz)
                {
                    mm++;
                    int perent=(i+1) * 100*mm/listbdz.Count / dt.Rows.Count;
                    wait.SetCaption( perent+ "%");

                    string dyid = psi.UID;
                    string connjz = " where SvgUID ='" + dyid + "' and Type='03'";
                    IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz);
                    DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listatt, typeof(PSPDEV));
                    if (listatt.Count>0)
                    {

                        DataRow[] xyrow=dataTable.Select(" Date1<="+year);
                        DataRow[] dyrow=dataTable.Select(" Date1>"+year ,"Date1");

                        if (dyrow.Length>0)
                        {
                            if (xyrow.Length>0)
                            {
                                int start=int.Parse(dyrow[0]["Date1"].ToString());
                                int end=int.Parse(dyrow[dyrow.Length-1]["Date1"].ToString());
                                //扩建
                                for (int j = start; j <= end; j++)
                                {
                                    DataRow[] curow=dataTable.Select(" Date1="+j );
                                    if (curow.Length==0)
                                    {
                                        continue;
                                    }
                                    Ps_Table_BuildPro table1 = new Ps_Table_BuildPro();
                                    table1.ID += "|" + GetProjectID;
                                    table1.Title = psi.Title;
                                    table1.ParentID = parentid;
                                    table1.ProjectID = GetProjectID;
                                    table1.BuildYear =j.ToString();
                                    table1.BuildEd = curow[0]["OperationYear"].ToString();
                                    table1.FromID = dy;
                                    table1.Volumn = double .Parse( curow[0]["SiN"].ToString());

                                    table1.Col4 = "bian";
                                    table1.Sort = OperTable.GetBuildProMaxSort() + 1;
                                    table1.Col10 = curow[0]["SUID"].ToString();
                                    table1.Col3="扩建";
                                    table1.AreaName = psi.AreaName;
                                    for (int k = 1; k < curow.Length; k++)
                                    {
                                        table1.Volumn += double .Parse( curow[k]["SiN"].ToString());

                                    }
                                    table1.GetType().GetProperty("y" + j).SetValue(table1, table1.Volumn, null);
                                    try
                                    {
                                         if (DTHave(dt2,curow[0]["SUID"].ToString()))
                                            {

                                                 UPDateOldBDZ(dt2,curow[0]["SUID"].ToString(),table1);
                                            }
                                            else
                                            {
                                                Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table1);
                                                dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow()));
                                                AddChildVol(table1, true);
                                            }

                                    }
                                      catch (Exception ee)
                                    {
                                        wait.Close();
                                    }
                                }

                            }
                            else
                            {
                                //新建+扩建
                                int start=int.Parse(dyrow[0]["Date1"].ToString());
                                int end=int.Parse(dyrow[dyrow.Length-1]["Date1"].ToString());
                                for (int j = start; j <= end; j++)
                                {
                                    DataRow[] curow=dataTable.Select(" Date1="+j );
                                    if (curow.Length==0)
                                    {
                                        continue;
                                    }
                                    if (j==start)//只有第一年需要新建,其后的都是扩建
                                    {
                                        Ps_Table_BuildPro table1 = new Ps_Table_BuildPro();
                                        table1.ID += "|" + GetProjectID;
                                        table1.Title = psi.Title;
                                        table1.ParentID = parentid;
                                        table1.ProjectID = GetProjectID;
                                        table1.BuildYear = j.ToString();
                                        table1.BuildEd = curow[0]["OperationYear"].ToString();
                                        table1.FromID = dy;
                                        table1.Volumn = double .Parse( curow[0]["SiN"].ToString());

                                        table1.Col4 = "bian";
                                        table1.Sort = OperTable.GetBuildProMaxSort() + 1;
                                        table1.Col10 = curow[0]["SUID"].ToString();
                                        table1.Col3="新建";
                                        table1.AreaName = psi.AreaName;
                                        for (int k = 1; k < curow.Length; k++)
                                        {
                                            table1.Volumn += double.Parse(curow[k]["SiN"].ToString());

                                        }
                                         table1.GetType().GetProperty("y" + j).SetValue(table1, table1.Volumn, null);
                                        try
                                        {
                                                if (DTHave(dt2,curow[0]["SUID"].ToString()))
                                                {

                                                     UPDateOldBDZ(dt2,curow[0]["SUID"].ToString(),table1);
                                                }
                                                else
                                                {
                                                     Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table1);
                                                     dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow()));
                                                     AddChildVol(table1, true);
                                                }

                                        }
                                          catch (Exception ee)
                                        {
                                            wait.Close();
                                        }

                                    }
                                    else
                                    {

                                             Ps_Table_BuildPro table2 = new Ps_Table_BuildPro();
                                            table2.ID += "|" + GetProjectID;
                                            table2.Title = psi.Title;
                                            table2.ParentID = parentid;
                                            table2.ProjectID = GetProjectID;
                                            table2.BuildYear = j.ToString();
                                            table2.BuildEd =  curow[0]["OperationYear"].ToString();
                                            table2.FromID = dy;
                                            table2.Volumn = double .Parse( curow[0]["SiN"].ToString());

                                            table2.Col4 = "bian";
                                            table2.Sort = OperTable.GetBuildProMaxSort() + 1;
                                            table2.Col10 = curow[0]["SUID"].ToString();
                                            table2.Col3="扩建";
                                            table2.AreaName = psi.AreaName;
                                            for (int k = 1; k < curow.Length; k++)
                                            {
                                                table2.Volumn += double .Parse( curow[k]["SiN"].ToString());

                                            }
                                            table2.GetType().GetProperty("y" + j).SetValue(table2, table2.Volumn, null);
                                            try
                                            {
                                                 if (DTHave(dt2,curow[0]["SUID"].ToString()))
                                                {

                                                     UPDateOldBDZ(dt2,curow[0]["SUID"].ToString(),table2);
                                                }
                                                else
                                                {
                                                     Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table2);
                                                     dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table2, dataTable.NewRow()));
                                                     AddChildVol(table2, true);
                                                }

                                            }
                                              catch (Exception ee)
                                            {
                                                wait.Close();
                                            }
                                    }

                                }

                            }
                        }

                    }
                    else
                    {
                        int curyear = 0;
                        int.TryParse(psi.L28, out curyear);
                        if (curyear> year)
                        {

                            Ps_Table_BuildPro table1 = new Ps_Table_BuildPro();
                            table1.ID += "|" + GetProjectID;
                            table1.Title = psi.Title;
                            table1.ParentID = parentid;
                            table1.ProjectID = GetProjectID;
                            table1.BuildYear = psi.L28;
                            table1.BuildEd = psi.S2;
                            table1.FromID = dy;
                            table1.Volumn = psi.L2;

                            //  table1.BefVolumn = frm.AllVol;
                            table1.GetType().GetProperty("y" + psi.L28).SetValue(table1, psi.L2, null);
                            table1.Col4 = "bian";
                            table1.Sort = OperTable.GetBuildProMaxSort() + 1;
                            table1.Col10 = psi.UID;
                            table1.Col3="新建";
                            table1.AreaName = psi.AreaName;
                            try
                            {
                                 if (DTHave(dt2,psi.UID))
                                {

                                     UPDateOldBDZ(dt2,psi.UID,table1);
                                }
                                else
                                {
                                     Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table1);
                                     dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow()));
                                     AddChildVol(table1, true);
                                }

                            }
                            catch (Exception ee)
                            {
                                wait.Close();
                            }
                        }

                    }

                }

            }

            LoadData1();
            wait.Close();
        }
Exemplo n.º 21
0
        public void FileReadV(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf, bool shortiflag, StringBuilder duanResult)
        {
            FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
            StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
            string strLineGU;
            string[] arrayGU;
            char[] charSplitGU = new char[] { ' ' };
            int intshorti = 0;
            while ((strLineGU = readLineGU.ReadLine()) != null)
            {

                arrayGU = strLineGU.Split(charSplitGU, StringSplitOptions.RemoveEmptyEntries);
                string[] shorti = arrayGU;
                shorti.Initialize();
                //int m = 0;
                //foreach (string str in arrayGU)
                //{

                //    if (str != "")
                //    {

                //        shorti[m++] = str.ToString();

                //    }
                //}
                if (intshorti == 0)
                {
                    if (!shortiflag)
                    {
                        duanResult.Append(shorti[0] + "," + shorti[1] + "," + shorti[3] + "\r\n");
                        shortiflag = true;
                    }

                }
                else
                    duanResult.Append(shorti[0] + "," + shorti[1] + "," + Convert.ToDouble(shorti[3]) + "\r\n");

                intshorti++;
                wf.SetCaption(intshorti.ToString());
            }
            readLineGU.Close();
        }
Exemplo n.º 22
0
        public void FileReadDV(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf, string con, StringBuilder dianYaResult)
        {
            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
            {
            }
            else
            {
                return;
            }
            FileStream dianYa = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt", FileMode.Open);
            StreamReader readLineDY = new StreamReader(dianYa, System.Text.Encoding.Default);
            string strLineDY;
            string[] arrayDY;
            char[] charSplitDY = new char[] { ' ' };
            strLineDY = readLineDY.ReadLine();
            int j = 0;
            int muxiannum = 0;
            while (strLineDY != null)
            {
                arrayDY = strLineDY.Split(charSplitDY, StringSplitOptions.RemoveEmptyEntries);

                //int m = 0;
                string[] dev = arrayDY;
                //dev.Initialize();
                //foreach (string str in arrayDY)
                //{
                //    if (str != "")
                //    {
                //        dev[m++] = str;
                //    }
                //}
                if (j == 0)
                {
                    //dianYaResult += "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n";
                    dianYaResult.Append(dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
             dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "\r\n");
                }
                else
                {
                    if (dev[0] == "����ĸ��")
                    {
                        dianYaResult.Append("\r\n" + "����ĸ�ߣ�" + dev[1] + "\r\n");
                    }
                    else
                    {
                        bool dianyaflag = true;     //�жϴ�ĸ���Ƕ�·��ĸ�߻���һ���ĸ��
                        PSPDEV CR = new PSPDEV();

                        if (dev[1] != "du")
                        {

                            con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                            if (CR == null)
                            {
                                dianyaflag = false;
                            }
                        }
                        //else
                        //{
                        //    dianyaflag = false;
                        //    CR.Name = duanluname;
                        //    CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByNameANDSVG", CR);
                        //}
                        if (dianyaflag)
                            dianYaResult.Append(dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," +
                                dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + "," + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n");
                        //else
                        //    dianYaResult.Append( dev[0] + "," + duanluname + "�϶�·��" + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," +
                        //       dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n";
                    }

                }
                strLineDY = readLineDY.ReadLine();
                muxiannum++;
                j++;
                wf.SetCaption(muxiannum.ToString());
            }
            readLineDY.Close();
        }
Exemplo n.º 23
0
        /// <summary>
        /// 格式化标题
        /// </summary>
        private void ViewTitle()
        {
            float SheetCount1 = SheetCount;
            float percent     = 0;

            #region SetRowHeader
            //fpSpread1.ActiveSheet.RowHeader.Visible = true;
            ////FarPoint.Win.Spread.SheetView.DocumentModels dm = new FarPoint.Win.Spread.SheetView.DocumentModels();
            ////dm = fpSpread1.ActiveSheet.Models;
            //fpSpread1.ActiveSheet.RowHeaderColumnCount = 1;
            ////dm.RowHeaderSpan.Add(1, 1, 1, 4);
            #endregion

//==================================================================================================================
            /*这个是在电力实绩取数据现在不用,现在在分区县供电实绩*/
            #region SetYears表4_1主表的数据部分
            IntCol = 1;
            //   PF.SetYears("电力发展实绩", this, fpSpread1.Sheets[0], 5, IntCol, 1, 1);
            // MergeLength = PF.GolobalYearCount - (PF.GolobalYears / 3);//GolobalYears年份没有数据的不显示出来除3是多循环2个一级目录(市辖供电区,县级供电区)
            ////算法添加
            // PF.SheetNFormula(fpSpread1.Sheets[0],5,3);
            #endregion

            #region SetSheet_4_1主表
            if (!IsCreateSheet)
            {
                fpSpread1.Sheets[0].RowCount    = 0;
                fpSpread1.Sheets[0].ColumnCount = 0;
                percent = 1 / SheetCount1;
                wait.SetCaption("正在更新数据..." + percent.ToString("P"));
            }
            else
            {
                percent = 1 / SheetCount1;
                wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            }
            S4_1.SetSheet4_1Title(this, this.fpSpread1.Sheets[0], strTitle[0]);
            //===========================================================================================================
            if (!IsCreateSheet)
            {
                fpSpread1.Sheets[1].RowCount    = 0;
                fpSpread1.Sheets[1].ColumnCount = 0;
                percent = 2 / SheetCount1;
                wait.SetCaption("正在更新数据..." + percent.ToString("P"));
            }
            else
            {
                percent = 2 / SheetCount1;
                wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            }
            ////S4_1_1.SetSheet4_1_1Title(this, this.fpSpread1.Sheets[1], strTitle[1]);
            this.barEditItem2.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
            //this.lookUpEdit1.Visible = true;
            //S4_2_1.AddLookUpEditValue(this.lookUpEdit1,this);
            if (!IsCreateSheet)
            {
                fpSpread1.Sheets[2].RowCount    = 0;
                fpSpread1.Sheets[2].ColumnCount = 0;
                percent = 3 / SheetCount1;
                wait.SetCaption("正在更新数据..." + percent.ToString("P"));
            }
            else
            {
                percent = 3 / SheetCount1;
                wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            }
            S4_2.SetSheet4_2Title(fpSpread1.Sheets[1], strTitle[1]);
            S4_2_1.AddBarEditItems(this.barEditItem2, this.barEditItem1, this);
            this.barEditItem2.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            if (!IsCreateSheet)
            {
                fpSpread1.Sheets[3].RowCount    = 0;
                fpSpread1.Sheets[3].ColumnCount = 0;
                percent = 4 / SheetCount1;
                wait.SetCaption("正在更新数据..." + percent.ToString("P"));
            }
            else
            {
                percent = 4 / SheetCount1;
                wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            }
            ////S4_2_1.SetSheet4_2_1Title(fpSpread1.Sheets[3], strTitle[3]);

            //this.lookUpEdit1.Visible = false;
            if (!IsCreateSheet)
            {
                fpSpread1.Sheets[4].RowCount    = 0;
                fpSpread1.Sheets[4].ColumnCount = 0;
                percent = 5 / SheetCount1;
                wait.SetCaption("正在更新数据..." + percent.ToString("P"));
            }
            else
            {
                percent = 5 / SheetCount1;
                wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            }
            S4_3.SetSheet4_3Title(fpSpread1, fpSpread1.Sheets[2], strTitle[2]);
            //this.barEditItem2.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
            if (!IsCreateSheet)
            {
                fpSpread1.Sheets[5].RowCount    = 0;
                fpSpread1.Sheets[5].ColumnCount = 0;
                percent = 6 / SheetCount1;
                wait.SetCaption("正在更新数据..." + percent.ToString("P"));
            }
            else
            {
                percent = 6 / SheetCount1;
                wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            }
            S4_4.SetSheet4_4Title(fpSpread1.Sheets[3], strTitle[3]);
            if (!IsCreateSheet)
            {
                fpSpread1.Sheets[6].RowCount    = 0;
                fpSpread1.Sheets[6].ColumnCount = 0;
                percent = 7 / SheetCount1;
                wait.SetCaption("正在更新数据..." + percent.ToString("P"));
            }
            else
            {
                percent = 7 / SheetCount1;
                wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            }
            S4_4_1.SetSheet4_4_1Title(fpSpread1.Sheets[4], strTitle[4]);
            if (!IsCreateSheet)
            {
                fpSpread1.Sheets[7].RowCount    = 0;
                fpSpread1.Sheets[7].ColumnCount = 0;
                percent = 8 / SheetCount1;
                wait.SetCaption("正在更新数据..." + percent.ToString("P"));
            }
            else
            {
                percent = 8 / SheetCount1;
                wait.SetCaption("正在加载数据..." + percent.ToString("P"));
            }
            S4_5.SetSheet4_5Title(fpSpread1, fpSpread1.Sheets[5], strTitle[5]);
            //this.barEditItem2.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            this.AddCellChanged();
            PF.Sheet_AutoLineFeed(fpSpread1);//设置整个工作簿换行
            #endregion
        }
        /// <summary>
        /// 加载GDP数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.Nodes.Count<0)
            {
                return;
            }
            MessageBox.Show("请选择GDP一产、二产、三产数据");
            FormForecastLoadData2 ffs = new FormForecastLoadData2();
            ffs.ISGDP = true;
            ffs.PID = MIS.ProgUID;
            ffs.StartYear = forecastReport.StartYear;
            ffs.EndYear = forecastReport.EndYear;
            if (ffs.ShowDialog() != DialogResult.OK)
                return;

            Hashtable hs = ffs.HS;

            if (hs.Count == 0)
                return;
            DataRow gdprow = gdprows[0];
            DataRow gdprow01 = gdprows01[0];
            DataRow gdprow02 = gdprows02[0];
            DataRow gdprow03 = gdprows03[0];

            Ps_History gdph01 = null;
            Ps_History gdph02 = null;
            Ps_History gdph03 = null;
            bool have = false;
            foreach (Ps_History de3 in hs.Values)
            {
                if (de3.Title.Contains("一产"))
                {
                    gdph01 = de3;
                    have = true;
                    continue;
                }
                if (de3.Title.Contains("二产"))
                {
                    gdph02 = de3;
                    have = true;
                    continue;
                }
                if (de3.Title.Contains("三产"))
                {
                    gdph03 = de3;
                    have = true;
                    continue;
                }
            }

            if (have)
            {
                double db01 = 0;
                double db02 = 0;
                double db03 = 0;
                WaitDialogForm wait = new WaitDialogForm("", "正在载入数据,请稍后...");
                treeList1.BeginInit();
                int sum = forecastReport.EndYear - forecastReport.StartYear;
                for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
                {
                    int per = (i - forecastReport.StartYear) * 100 / sum;
                    wait.SetCaption(per + "%");
                    if (gdph01!=null)
                    {
                        gdprow01["y" + i] = gdph01.GetType().GetProperty("y" + i).GetValue(gdph01, null);
                        //commonhelp.ResetValue(gdprow01["ID"].ToString(), "y" + i);
                    }
                    if (gdph02 != null)
                    {
                        gdprow02["y" + i] = gdph02.GetType().GetProperty("y" + i).GetValue(gdph02, null);
                        //commonhelp.ResetValue(gdprow02["ID"].ToString(), "y" + i);
                    }
                    if (gdph03 != null)
                    {
                        gdprow03["y" + i] = gdph03.GetType().GetProperty("y" + i).GetValue(gdph03, null);
                        //commonhelp.ResetValue(gdprow03["ID"].ToString(), "y" + i);
                    }

                    db01 = double.Parse(gdprow01["y" + i].ToString());
                    db02 = double.Parse(gdprow02["y" + i].ToString());
                    db03 = double.Parse(gdprow03["y" + i].ToString());

                    gdprow["y" + i] = db01 + db02 + db03;
                }

                Ps_Forecast_Math gdppfm01 = DataConverter.RowToObject<Ps_Forecast_Math>(gdprow01);
                Ps_Forecast_Math gdppfm02 = DataConverter.RowToObject<Ps_Forecast_Math>(gdprow02);
                Ps_Forecast_Math gdppfm03 = DataConverter.RowToObject<Ps_Forecast_Math>(gdprow03);
                Ps_Forecast_Math gdppfm = DataConverter.RowToObject<Ps_Forecast_Math>(gdprow);

                Common.Services.BaseService.Update<Ps_Forecast_Math>(gdppfm01);
                Common.Services.BaseService.Update<Ps_Forecast_Math>(gdppfm02);
                Common.Services.BaseService.Update<Ps_Forecast_Math>(gdppfm03);
                Common.Services.BaseService.Update<Ps_Forecast_Math>(gdppfm);
                treeList1.EndInit();
                wait.Close();
                GDPIncrease();
            }
            RefreshChart();
        }
        private void btnControl_btnEventExcel_Click(object sender, EventArgs e)
        {
            WaitDialogForm waitDialogForm = new WaitDialogForm("Đang xuất excel ...", "Vui lòng chờ giây lát !");

            try
            {
                ExcelManager excelManager = new ExcelManager(true);

                // Print band header
                BandedGridView view = gvGrid;
                view.ExpandAllGroups();
                object[] data = new object[view.VisibleColumns.Count];
                excelManager.BandedGridHeader2Excel(view, false, 6, 1, "headerRangeName");
                excelManager.SetTitleRows();
                excelManager.SelectRange()
                .SetFontFamily("Times New Roman");

                waitDialogForm.SetCaption(String.Format("{0} - {1}%", "Đang xuất excel ...", 50));

                excelManager.GridData2Excel(gvGrid, 7, 1, false, false, "", false, false);

                //excelManager.SelectRange(excelManager.WorkingRange.Row + excelManager.WorkingRange.Rows.Count, excelManager.WorkingRange.Column,
                //    excelManager.WorkingRange.Row + excelManager.WorkingRange.Rows.Count, excelManager.WorkingRange.Column + excelManager.WorkingRange.Columns.Count - 1);


                // Save working range
                //excelManager.MoveRange(2, 0);
                //int maxCol = 12;
                //int xtraCol = 2;

                int sr = excelManager.WorkingRange.Row + 1;
                int sc = excelManager.WorkingRange.Column;
                int er = excelManager.WorkingRange.Row + 1;
                int ec = excelManager.WorkingRange.Column + excelManager.WorkingRange.Columns.Count - 1;

                //excelManager.SelectRange(8, 1, 8, maxCol).SetRowHeight("", 45);

                ////Dòng Title
                excelManager
                .SelectRange(1, 1, 1, 1)
                .SetFontStyle(true, false, false)
                .SetFontSize(12)
                .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft)
                .SetRangeValue(clsParameter.pParentHospital);

                excelManager
                .SelectRange(2, 1, 2, 1)
                .SetFontStyle(false, false, false)
                .SetFontSize(12)
                .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft)
                .SetRangeValue(clsParameter.pHospital);

                excelManager
                .SelectRange(4, 1, 4, ec)
                .Merge()
                .SetFontStyle(true, false, false)
                .SetFontSize(16)
                .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                .SetRangeValue("DANH SÁCH TRẺ KHUYẾT TẬT VÀ CON NGƯỜI KHUYẾT TẬT");

                excelManager.SelectRange(11, 2, er, ec).AutoFitColumn();
                //excelManager.SelectRange(11, 2, er, ec).SetNumberFormat("#,#0");

                // excelManager
                // .SelectRange(er + 2, ec - 3, er + 2, ec)
                // .Merge()
                // .SetFontStyle(false, false, false)
                // .SetFontSize(12)
                // .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                // .SetRangeValue(string.Format("Ngày {0} tháng {1} năm {2}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year));

                // excelManager
                // .SelectRange(er + 3, ec - 3, er + 3, ec)
                // .Merge()
                // .SetFontStyle(false, false, false)
                // .SetFontSize(12)
                // .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                // .SetRangeValue("Thư ký");

                // excelManager
                // .SelectRange(er + 6, ec - 3, er + 6, ec)
                // .Merge()
                // .SetFontStyle(false, false, false)
                // .SetFontSize(12)
                // .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                // .SetRangeValue(clsParameter.pThuKy);

                // excelManager
                // .SelectRange(er + 3, 3, er + 3, 4)
                // .Merge()
                // .SetFontStyle(false, false, false)
                // .SetFontSize(12)
                // .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                // .SetRangeValue("Giám đốc");

                // excelManager
                //.SelectRange(er + 6, 3, er + 6, 4)
                //.Merge()
                //.SetFontStyle(false, false, false)
                //.SetFontSize(12)
                //.SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                //.SetRangeValue(clsParameter.pGiamDoc);
            }
            catch (Exception)
            {
                XtraMessageBox.Show("Lỗi trong quá trình xuất Excel.\nVui lòng kiểm tra lại biểu mẫu hoặc tài liệu đang mở.", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                //Marshal.ReleaseComObject(excelSheet);
                //Marshal.ReleaseComObject(excelBook);
                //Marshal.ReleaseComObject(books);
                //Marshal.ReleaseComObject(excel);

                waitDialogForm.Close();
            }
        }
        //按总值计算
        private void CalcAll()
        {
            if (firstyear == "0" || endyear == "0")
            {
                MsgBox.Show("请设置历史数据起始年结束年后再点参数设置");
                return;
            }
            treeList1.BeginInit();
            WaitDialogForm wait = new WaitDialogForm("", "正在重新计算,请稍后...");

            int allsum = forecastReport.YcEndYear - forecastReport.StartYear;

            if (gdprows.Length>0&&dlrows.Length>0&&dhrows.Length>0)
            {
                DataRow gdprow = gdprows[0];
                DataRow dlrow = dlrows[0];
                DataRow dhrow = dhrows[0];

                for (int i = forecastReport.StartYear; i <= forecastReport.EndYear; i++)
                {
                    wait.SetCaption((i - forecastReport.StartYear) * 100 / allsum + "%");
                    double gdp = double.Parse(gdprow["y" + i].ToString());
                    double dl = double.Parse(dlrow["y" + i].ToString());
                    double dh = double.Parse(dhrow["y" + i].ToString());
                    if (gdp != 0)
                    {
                        dh = dl * unitdata / gdp;
                    }
                    else
                    {
                        dh = 0;
                    }

                    dhrow["y" + i]= Math.Round(dh, 4);
                    //commonhelp.ResetValue(dhrow["ID"].ToString(), "y" + i);
                }
                Ps_Forecast_Math dhpfm = DataConverter.RowToObject<Ps_Forecast_Math>(dhrow);

                Common.Services.BaseService.Update<Ps_Forecast_Math>(dhpfm);

                for (int i = forecastReport.YcStartYear; i <= forecastReport.YcEndYear; i++)
                {
                    wait.SetCaption((i - forecastReport.StartYear) * 100 / allsum + "%");
                    double gdp = double.Parse(gdprow["y" + i].ToString());
                    double dl = double.Parse(dlrow["y" + i].ToString());
                    double dh = double.Parse(dhrow["y" + i].ToString());
                    dl = dh * gdp / unitdata;
                    dlrow["y" + i] = Math.Round(dl, 4);
                    //commonhelp.ResetValue(dlrow["ID"].ToString(), "y" + i);
                }
                dlrow["Col4"] = "yes";
                Ps_Forecast_Math dlpfm = DataConverter.RowToObject<Ps_Forecast_Math>(dlrow);
                Common.Services.BaseService.Update<Ps_Forecast_Math>(dlpfm);

            }
            else
            {
                MessageBox.Show("记录不正确,无法计算!");
            }
            treeList1.EndInit();
            wait.Close();
        }