private void simpleButton1_Click(object sender, EventArgs e) { if (comboBoxEdit3.Text == "") { MessageBox.Show("竣工年份不能为空"); return; } if (comboBoxEdit2.Text != "") { if (int.Parse(comboBoxEdit3.Text) < int.Parse(comboBoxEdit2.Text)) { MessageBox.Show("结束年必须大于开工年!"); return; } } DialogResult = DialogResult.OK; Ps_Table_Edit edit = new Ps_Table_Edit(); edit.ID += "|" + GetProject; edit.ParentID = parentid; edit.StartYear = comboBoxEdit2.Text; edit.FinishYear = comboBoxEdit3.Text; edit.ProjectID = projectid; edit.Status = "新建"; edit.Volume = spinEdit1.Text; edit.Col1 = comboBoxEdit1.Text; try { edit.Sort = OperTable.GetChildMaxSort() + 1; } catch { edit.Sort = 4; } if (edit.Sort < 4) { edit.Sort = 4; } Common.Services.BaseService.Create("InsertPs_Table_Edit", edit); }
public void InitCom() { OperTable oper=new OperTable(); IList<string> list = oper.GetLineS1("1=1"); foreach (string str in list) comboBoxEdit1.Properties.Items.Add(str); if (comboBoxEdit1.Properties.Items.Count > 0) comboBoxEdit1.SelectedIndex = 0; }
public void InitCom() { OperTable oper = new OperTable(); //IList<string> list = oper.GetLineS1("1=1"); //foreach (string str in list) // comboBoxEdit1.Properties.Items.Add(str); //if (comboBoxEdit1.Properties.Items.Count > 0) // comboBoxEdit1.SelectedIndex = 0; }
private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (this.gridView2.FocusedRowHandle > -1) { IList <string> filedList = new List <string>(); IList <string> capList = new List <string>(); for (int i = 0; i < gridView1.Columns.Count; i++) { capList.Add(gridView1.Columns[i].Caption); filedList.Add(gridView1.Columns[i].FieldName); } OpenFileDialog op = new OpenFileDialog(); op.Filter = "Excel文件(*.xls)|*.xls"; if (op.ShowDialog() == DialogResult.OK) { try { DataTable table = OperTable.GetExcel(op.FileName, filedList, capList); for (int i = 0; i < table.Rows.Count; i++) { if (table.Rows[i][0].ToString().IndexOf("合计") > 0 || table.Rows[i][1].ToString().IndexOf("合计") > 0) { continue; } PSP_PowerSubstationInfo area = new PSP_PowerSubstationInfo(); area.UID = Guid.NewGuid().ToString() + "|" + ProjectID; area.AreaID = ProjectID; area.CreateDate = DateTime.Now; string f = this.gridView2.GetRowCellValue(this.gridView2.FocusedRowHandle, "Title").ToString(); if (f == "现状") { f = "1"; } else if (f == "规划") { f = "2"; } area.Flag = f; foreach (DataColumn col in table.Columns) { area.GetType().GetProperty(col.ColumnName).SetValue(area, table.Rows[i][col].ToString(), null); } Common.Services.BaseService.Create <PSP_PowerSubstationInfo>(area); } } catch (Exception a) { MessageBox.Show(a.Message); } InitGrid1(); } } else { MessageBox.Show("没有选择规划或现状", "导入EXCEL", MessageBoxButtons.OK); } }
protected bool SaveRecord() { try { _obj.GDPper = Math.Round((_obj.Population == 0.0 ? 0.0 : 10000 * _obj.GDP / _obj.Population), 2); if (IsCreate) { //Ps_Table_GDP pg = new Ps_Table_GDP(); //pg.ID = _obj.ID; //pg.GDP = _obj.GDP; //pg.Population = _obj.Population; //pg.Yearf = _obj.Yearf; //pg.GDPrate = _obj.GDPrate; _obj.ID += "|" + projectid; _obj.ParentID = parentid; _obj.ProjectID = projectid; _obj.SortID = OperTable.GetGDPMaxSort() + 1; IList <Ps_Table_GDP> list = Common.Services.BaseService.GetList <Ps_Table_GDP>("SelectPs_Table_GDPByConn", " ProjectID='" + _obj.ProjectID + "' and ParentID='" + _obj.ParentID + "' and Yearf='" + _obj.Yearf + "'"); if (list.Count > 0) { MessageBox.Show("创建的年份不能够重复!"); _obj = new Ps_Table_GDP(); IList <Ps_Table_GDP> list1 = new List <Ps_Table_GDP>(); list1.Add(_obj); this.vGridControl.DataSource = list1; return(false); } Services.BaseService.Create <Ps_Table_GDP>(_obj); } else { IList <Ps_Table_GDP> list = Common.Services.BaseService.GetList <Ps_Table_GDP>("SelectPs_Table_GDPByConn", " ProjectID='" + _obj.ProjectID + "' and ParentID='" + _obj.ParentID + "' and Yearf='" + _obj.Yearf + "'"); foreach (Ps_Table_GDP pg in list) { if (pg.ID != _obj.ID) { MessageBox.Show("已经存在此年数据,请重新修改!"); return(false); } } Services.BaseService.Update <Ps_Table_GDP>(_obj); } } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return(false); } //操作已成功 return(true); }
private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (this.gridView2.FocusedRowHandle > -1) { IList <string> filedList = new List <string>(); IList <string> capList = new List <string>(); for (int i = 0; i < gridView1.Columns.Count; i++) { capList.Add(gridView1.Columns[i].Caption); filedList.Add(gridView1.Columns[i].FieldName); } OpenFileDialog op = new OpenFileDialog(); op.Filter = "Excel文件(*.xls)|*.xls"; if (op.ShowDialog() == DialogResult.OK) { try { DataTable table = OperTable.GetExcel(op.FileName, filedList, capList); for (int i = 0; i < table.Rows.Count; i++) { if (table.Rows[i][0].ToString().IndexOf("合计") > 0 || table.Rows[i][1].ToString().IndexOf("合计") > 0) { continue; } Ps_Table_GDP area = new Ps_Table_GDP(); area.ID += "|" + ProjectID; area.SortID = OperTable.GetGDPMaxSort() + 1; area.ParentID = this.gridView2.GetRowCellValue(this.gridView2.FocusedRowHandle, "ID").ToString(); area.ProjectID = ProjectID; foreach (DataColumn col in table.Columns) { if (col.ColumnName == "Yearf") { area.GetType().GetProperty(col.ColumnName).SetValue(area, int.Parse(table.Rows[i][col].ToString()), null); } else { area.GetType().GetProperty(col.ColumnName).SetValue(area, double.Parse(table.Rows[i][col].ToString()), null); } } Common.Services.BaseService.Create <Ps_Table_GDP>(area); } } catch { } InitGrid1(); } } else { MessageBox.Show("没有选择地区(如果没有请添加一个)", "导入EXCEL", MessageBoxButtons.OK); } }
private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { IList <string> filedList = new List <string>(); IList <string> capList = new List <string>(); for (int i = 0; i < gridView2.Columns.Count; i++) { if (gridView2.Columns[i].Visible == true) { capList.Add(gridView2.Columns[i].Caption); filedList.Add(gridView2.Columns[i].FieldName); } } OpenFileDialog op = new OpenFileDialog(); op.Filter = "Excel文件(*.xls)|*.xls"; if (op.ShowDialog() == DialogResult.OK) { try { DataTable table = OperTable.GetExcel(op.FileName, filedList, capList); for (int i = 0; i < table.Rows.Count; i++) { if (table.Rows[i][0].ToString().IndexOf("建表时间") >= 0) { continue; } PS_Table_Area_TYPE area = new PS_Table_Area_TYPE(); area.ID += "|" + ProjectID; area.ProjectID = ProjectID; foreach (DataColumn col in table.Columns) { if (col.ColumnName == "Yearf") { area.GetType().GetProperty(col.ColumnName).SetValue(area, int.Parse(table.Rows[i][col].ToString()), null); } else { area.GetType().GetProperty(col.ColumnName).SetValue(area, table.Rows[i][col].ToString(), null); } } Common.Services.BaseService.Create <PS_Table_Area_TYPE>(area); } } catch { } InitGrid2(); } }
protected bool SaveRecord() { try { if (IsCreate) { string id = _obj.ID; _obj.ID += "|" + projectid; _obj.ParentID = parentid; _obj.ProjectID = projectid; _obj.SortID = OperTable.GetAreaMaxSort() + 1; IList <Ps_Table_AreaData> list = Common.Services.BaseService.GetList <Ps_Table_AreaData>("SelectPs_Table_AreaDataByConn", " ParentID='" + parentid + "' and ProjectID='" + projectid + "'and Yearf='" + _obj.Yearf + "'"); if (list.Count > 0) { MessageBox.Show("存在重复年份,请重新添加年份!"); _obj.ID = id; return(false); } Services.BaseService.Create <Ps_Table_AreaData>(_obj); } else { IList <Ps_Table_AreaData> list = Common.Services.BaseService.GetList <Ps_Table_AreaData>("SelectPs_Table_AreaDataByConn", " ParentID='" + parentid + "' and ProjectID='" + projectid + "'and Yearf='" + _obj.Yearf + "'"); foreach (Ps_Table_AreaData pa in list) { if (pa.ID != _obj.ID) { MessageBox.Show("存在重复年份,请重新添加年份!"); return(false); } } Services.BaseService.Update <Ps_Table_AreaData>(_obj); } } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return(false); } //操作已成功 return(true); }
//添加地区 private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FrmAddPN frm = new FrmAddPN(); frm.SetFrmName = "添加地区"; frm.SetLabelName = "地区名称"; if (frm.ShowDialog() == DialogResult.OK) { Ps_Table_GDP data = new Ps_Table_GDP(); data.ID += "|" + ProjectID; data.ParentID = "0"; data.ProjectID = ProjectID; data.SortID = OperTable.GetGDPMaxSort() + 1; data.Area = frm.ParentName; Common.Services.BaseService.Create <Ps_Table_GDP>(data); } InitGrid2(); }
//增加 private void simpleButton1_Click(object sender, EventArgs e) { if (comboBoxEdit3.Text == "") { MessageBox.Show("竣工年份不能为空"); return; } if (comboBoxEdit1.Text != "已有" && comboBoxEdit2.Text != "") { if (int.Parse(comboBoxEdit3.Text) < int.Parse(comboBoxEdit2.Text)) { MessageBox.Show("竣工年必须大于开工年!"); return; } } // DialogResult = DialogResult.OK; Ps_Table_Edit edit = new Ps_Table_Edit(); edit.ID += "|" + GetProject; edit.ParentID = parentid; edit.StartYear = comboBoxEdit1.Text == "已有" ? "" : comboBoxEdit2.Text; edit.FinishYear = comboBoxEdit1.Text == "已有" ? "" : comboBoxEdit3.Text; edit.Status = comboBoxEdit1.Text; edit.Volume = this.spinEdit1.Text; edit.ProjectID = GetProject; edit.Col4 = mark; try { edit.Sort = OperTable.GetChildMaxSort() + 1; } catch { edit.Sort = 4; } if (edit.Sort < 4) { edit.Sort = 4; } Common.Services.BaseService.Create("InsertPs_Table_Edit", edit); strResult.Add(textEdit1.Text); strResult.Add(comboBoxEdit3.Text); strResult.Add(spinEdit1.Value.ToString()); string conn = "ParentID='" + parentid + "'"; list = Common.Services.BaseService.GetList <Ps_Table_Edit>("SelectPs_Table_EditListByConn", conn); LoadGridData(); label7.Text = GetCurVolumn(); }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FrmAddTzgsWH2pw frm = new FrmAddTzgsWH2pw(); frm.Text = "增加"; // frm.Stat = focusedNode.GetValue("Col2").ToString(); // frm.SetLabelName = "子分类名称"; if (frm.ShowDialog() == DialogResult.OK) { Ps_Table_TZGS table1 = new Ps_Table_TZGS(); table1.ID += "|" + GetProjectID; frm.tzgspwid = table1.ID; table1.Title = frm.ParentName; table1.ParentID = "0";// focusedNode.GetValue("ID").ToString(); table1.ProjectID = GetProjectID; table1.BuildYear = frm.StartYear; table1.BuildEd = frm.FinishYear; table1.FromID = "0"; //table1.AllVolumn = frm.AllVol; //table1.AftVolumn = frm.AllVol; table1.LineInfo = frm.LineInfo; table1.BianInfo = frm.BianInfo; table1.AreaName = frm.AreaName; table1.Length = frm.LineLen; table1.Length2 = frm.LineLen2; table1.Sort = OperTable.GetTZGSMaxSort() + 1; table1.Col3 = frm.Col3; table1.Col1 = frm.BieZhu; table1.DQ = frm.DQ; table1.JGNum = frm.JGNum; table1.WGNum = frm.WGNum; table1.ProgType = frm.ProgType; table1.Amount = frm.Amount; table1.Num6 = frm.Num6; table1.Col4 = "pw"; frm.StrType = "pw"; table1.Amount = frm.Amount; try { string pid = table1.ID; string tit = table1.Title; Common.Services.BaseService.Create("InsertPs_Table_TZGS", table1); frm.StrType = "pw-pb"; table1.Title = tit + "-配变"; table1.Col4 = "pw-pb"; //table1.Volumn = frm.Vol; table1.ParentID = pid; table1.ID = Guid.NewGuid().ToString(); table1.Num1 = frm.Num1; table1.Num2 = frm.Num2; table1.Num3 = frm.Num3; table1.Num4 = frm.Num4; table1.Num5 = frm.Num5; table1.Num6 = frm.Num6; table1.Amount = frm.Amount; Common.Services.BaseService.Create("InsertPs_Table_TZGS", table1); frm.StrType = "pw-kg"; table1.Title = tit + "-开关"; table1.Col4 = "pw-kg"; table1.ParentID = pid; table1.ID = Guid.NewGuid().ToString(); table1.Num1 = frm.Num1; table1.Num2 = frm.Num2; table1.Num3 = frm.Num3; table1.Num4 = frm.Num4; table1.Amount = frm.Amount; Common.Services.BaseService.Create("InsertPs_Table_TZGS", table1); frm.StrType = "pw-line"; table1.Title = tit + "-线路"; table1.Col4 = "pw-line"; table1.Length = frm.LineLen; table1.ParentID = pid; table1.ID = Guid.NewGuid().ToString(); table1.LineInfo = frm.LineInfo; table1.Num1 = frm.Num1; table1.Num2 = frm.Num2; table1.Num3 = frm.Num3; table1.Num4 = frm.Num4; table1.Num5 = frm.Num5; table1.Num6 = frm.Num6; table1.Length = frm.LineLen; table1.Length2 = frm.LineLen2; table1.Amount = frm.Amount; Common.Services.BaseService.Create("InsertPs_Table_TZGS", table1); LoadData(); } catch (Exception ex) { MsgBox.Show("增加工程出错:" + ex.Message); } } }
//导入数据 private void barButtonItem12_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { IList <string> filedList = new List <string>(); IList <string> capList = new List <string>(); for (int i = 0; i < gridView1.Columns.Count; i++) { if (gridView1.Columns[i].Visible == true) { capList.Add(gridView1.Columns[i].Caption); filedList.Add(gridView1.Columns[i].FieldName); } } OpenFileDialog op = new OpenFileDialog(); op.Filter = "Excel文件(*.xls)|*.xls"; string Message = ""; if (op.ShowDialog() == DialogResult.OK) { try { DataTable table = OperTable.GetExcel(op.FileName, filedList, capList); for (int i = 0; i < table.Rows.Count; i++) { if (table.Rows[i][0].ToString().IndexOf("建表时间") >= 0) { continue; } Ps_Table_Report area = new Ps_Table_Report(); area.ProjectID = MIS.ProgUID; foreach (DataColumn col in table.Columns) { if (col.ColumnName == "Num1" || col.ColumnName == "image1" || col.ColumnName == "image2") { //area.GetType().GetProperty(col.ColumnName).SetValue(area, Convert.ToInt32(table.Rows[i][col]), null); } else if (col.ColumnName == "TableID") { string con = " TableID='" + table.Rows[i][col].ToString() + "' and ProjectID='" + MIS.ProgUID + "'"; IList <Ps_Table_Report> templist = Common.Services.BaseService.GetList <Ps_Table_Report>("SelectPs_Table_ReportListByConn", con); if (templist.Count > 0) { Message = "[" + table.Rows[i][col].ToString() + "]"; } else { area.GetType().GetProperty(col.ColumnName).SetValue(area, table.Rows[i][col].ToString(), null); } } else { area.GetType().GetProperty(col.ColumnName).SetValue(area, table.Rows[i][col], null); } } area.Num1 = Convert.ToInt32(Common.Services.BaseService.GetObject("SelectPs_Table_ReportMaxNum1", " ProjectID='" + MIS.ProgUID + "'")) + 1; area.image1 = new byte[0]; area.image2 = new byte[0]; Common.Services.BaseService.Create <Ps_Table_Report>(area); } InitData(); MessageBox.Show("导入完成!"); if (Message.Length != 0) { MessageBox.Show("表标识" + Message + " 已经存在,未重复添加!"); } } catch { MessageBox.Show("格式有误,导入失败!"); } } }
//增加 private void simpleButton1_Click(object sender, EventArgs e) { if (comboBoxEdit3.Text == "") { MessageBox.Show("竣工年份不能为空"); return; } if (comboBoxEdit1.Text != "已有" && comboBoxEdit2.Text != "") { if (int.Parse(comboBoxEdit3.Text) < int.Parse(comboBoxEdit2.Text)) { MessageBox.Show("竣工年必须大于开工年!"); return; } } // DialogResult = DialogResult.OK; Ps_Table_Edit edit = new Ps_Table_Edit(); edit.ID += "|" + GetProject; edit.ParentID = parentid; edit.StartYear = comboBoxEdit1.Text == "已有" ? "" : comboBoxEdit2.Text; edit.FinishYear = comboBoxEdit1.Text == "已有" ? "" : comboBoxEdit3.Text; edit.Status = comboBoxEdit1.Text; edit.Volume = this.spinEdit1.Text; edit.ProjectID = GetProject; edit.Col4 = mark; try { edit.Sort = OperTable.GetChildMaxSort() + 1; } catch { edit.Sort = 4; } if (edit.Sort < 4) { edit.Sort = 4; } Common.Services.BaseService.Create("InsertPs_Table_Edit", edit); strResult.Add(textEdit1.Text); strResult.Add(comboBoxEdit3.Text); strResult.Add(spinEdit1.Value.ToString()); string conn = "ParentID='" + parentid + "'"; list = Common.Services.BaseService.GetList <Ps_Table_Edit>("SelectPs_Table_EditListByConn", conn); if (typeTable == "500") { Ps_Table_500PH table = new Ps_Table_500PH(); table = Common.Services.BaseService.GetOneByKey <Ps_Table_500PH>(parentid); if (comboBoxEdit1.Text == "扩建/改造") { for (int i = int.Parse(comboBoxEdit3.Text); i <= yearRange.FinishYear; i++) { string a = table.GetType().GetProperty("y" + i.ToString()).GetValue(table, null).ToString(); table.GetType().GetProperty("y" + i.ToString()).SetValue(table, Convert.ToDouble(a) + Convert.ToDouble(spinEdit1.Text), null); } Common.Services.BaseService.Update("UpdatePs_Table_500PH", table); } } else if (typeTable == "200") { Ps_Table_200PH table = new Ps_Table_200PH(); table = Common.Services.BaseService.GetOneByKey <Ps_Table_200PH>(parentid); if (comboBoxEdit1.Text == "扩建/改造") { for (int i = int.Parse(comboBoxEdit3.Text); i <= yearRange.FinishYear; i++) { string a = table.GetType().GetProperty("y" + i.ToString()).GetValue(table, null).ToString(); table.GetType().GetProperty("y" + i.ToString()).SetValue(table, Convert.ToDouble(a) + Convert.ToDouble(spinEdit1.Text), null); } Common.Services.BaseService.Update("UpdatePs_Table_200PH", table); } } else if (typeTable == "100") { Ps_Table_100PH table = new Ps_Table_100PH(); table = Common.Services.BaseService.GetOneByKey <Ps_Table_100PH>(parentid); if (comboBoxEdit1.Text == "扩建/改造") { for (int i = int.Parse(comboBoxEdit3.Text); i <= yearRange.FinishYear; i++) { string a = table.GetType().GetProperty("y" + i.ToString()).GetValue(table, null).ToString(); table.GetType().GetProperty("y" + i.ToString()).SetValue(table, Convert.ToDouble(a) + Convert.ToDouble(spinEdit1.Text), null); } Common.Services.BaseService.Update("UpdatePs_Table_100PH", table); } } LoadGridData(); label7.Text = GetCurVolumn(); }
//500千伏分区分年容载比计算表 private void build_500rzbtj() { Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>(); string title = "500千伏分区分年容载比计算表"; OperTable oper = new OperTable(); yAnge = oper.GetYearRange("Col5='" + GetProjectID + "' and Col4='" + OperTable.ph500 + "'"); System.Data.DataTable datatable = get500phtable(yAnge); System.Data.DataTable dt = ResultDataTable1(ConvertTreeListToDataTable(datatable, false, yAnge), ref viscol, yAnge); if (!shjjbyyear) { creatsheetbydt(title, dt, viscol); } else { recreatsheetbydt(title, dt, viscol, 1); } }