private void FrmProject_Sum_Load(object sender, EventArgs e) { InitRight(); this.gridBand40.Columns.Add(this.bandedGridColumn6); this.gridBand41.Columns.Add(this.bandedGridColumn7); this.gridBand42.Columns.Add(this.bandedGridColumn8); this.gridBand43.Columns.Add(this.bandedGridColumn9); this.gridBand44.Columns.Add(this.bandedGridColumn10); this.gridBand45.Columns.Add(this.bandedGridColumn11); this.gridBand46.Columns.Add(this.bandedGridColumn12); this.gridBand47.Columns.Add(this.bandedGridColumn13); this.gridBand48.Columns.Add(this.bandedGridColumn14); this.gridBand50.Columns.Add(this.bandedGridColumn17); try { PW_tb3a p = new PW_tb3a(); p.col1 = "'局属'"; p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy332", p); this.gridControl.DataSource = GetList(list); } catch (Exception e1) { MessageBox.Show(e1.Message); } }
/// <summary> /// 修改焦点对象 /// </summary> public void UpdateObject() { //获取焦点对象 PW_tb3a obj = FocusedObject; if (obj == null) { return; } obj.col2 = proguid; //创建对象的一个副本 PW_tb3a objCopy = new PW_tb3a(); DataConverter.CopyTo <PW_tb3a>(obj, objCopy); //执行修改操作 using (FrmPW_SumDialog dlg = new FrmPW_SumDialog()) { dlg.Object = objCopy; //绑定副本 if (dlg.ShowDialog() != DialogResult.OK) { return; } } //用副本更新焦点对象 DataConverter.CopyTo <PW_tb3a>(objCopy, obj); //刷新表格 gridControl.RefreshDataSource(); }
public IList <PW_tb3a> SumList(IList <PW_tb3a> _list) { IList <PW_tb3a> l = _list; if (_list.Count > 0) { PW_tb3a sum = new PW_tb3a(); sum.PQName = "合计"; for (int i = 0; i < _list.Count; i++) { sum.Num1 = sum.Num1 + _list[i].Num1; sum.Num2 = sum.Num2 + _list[i].Num2; sum.Num3 = sum.Num3 + _list[i].Num3; sum.Num4 = sum.Num4 + _list[i].Num4; sum.Num5 = sum.Num5 + _list[i].Num5; sum.Num6 = sum.Num6 + _list[i].Num6; sum.Num7 = sum.Num7 + _list[i].Num7; sum.Num8 = sum.Num8 + _list[i].Num8; sum.FZL = sum.FZL + _list[i].FZL; sum.KBS = sum.KBS + _list[i].KBS; sum.KG = sum.KG + _list[i].KG; sum.LineLength = sum.LineLength + _list[i].LineLength; sum.MaxFH = sum.MaxFH + _list[i].MaxFH; sum.SafeFH = sum.SafeFH + _list[i].SafeFH; sum.WG1 = sum.WG1 + _list[i].WG1; sum.WG2 = sum.WG2 + _list[i].WG2; } _list.Add(sum); } return(l); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string str = ""; if (comboBox1.Text == "局属") { str = "'局属'"; } if (comboBox1.Text == "专用") { str = "'专用'"; } if (comboBox1.Text == "全部") { str = "'局属','专用'"; } try { PW_tb3a p = new PW_tb3a(); p.col1 = str; p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy334", p); this.gridControl.DataSource = list; } catch (Exception e1) { MessageBox.Show(e1.Message); } }
/// <summary> /// 添加对象 /// </summary> public void AddObject() { //检查对象链表是否已经加载 if (ObjectList == null) { return; } //新建对象 PW_tb3a obj = new PW_tb3a(); obj.UID = Guid.NewGuid().ToString(); obj.col2 = proguid; //obj.S5 = type; //执行添加操作 using (FrmPW_SumDialog dlg = new FrmPW_SumDialog()) { dlg.IsCreate = true; //设置新建标志 dlg.Object = obj; if (dlg.ShowDialog() != DialogResult.OK) { return; } } //将新对象加入到链表中 ObjectList.Add(obj); //刷新表格,并将焦点行定位到新对象上。 gridControl.RefreshDataSource(); GridHelper.FocuseRow(this.advBandedGridView1, obj); }
public void loadData(string col1, string col2) { PW_tb3a p = new PW_tb3a(); p.col1 = col1; p.col2 = col2; p.col3 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy324", p); this.gridControl.DataSource = list; }
public IList <PW_tb3a> GetList(IList <PW_tb3a> list) { IList <PW_tb3a> list2 = new List <PW_tb3a>(); for (int i = 0; i < list.Count; i++) { PW_tb3a a = list[i]; a.MaxFH = a.Num1 + a.Num3; a.SafeFH = a.Num1 + a.Num2 + a.Num3 + a.Num4; a.KBS = i + 1; list2.Add(a); } return(list2); }
/// <summary> /// 删除焦点对象 /// </summary> public void DeleteObject() { if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes) { return; } int[] aa = advBandedGridView1.GetSelectedRows(); for (int i = 0; i < aa.Length; i++) { //获取焦点对象 PW_tb3a obj = (PW_tb3a)advBandedGridView1.GetRow(aa[i]); //FocusedObject; if (obj == null) { return; } //请求确认 //执行删除操作 try { Services.BaseService.Delete <PW_tb3a>(obj); } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return; } // this.advBandedGridView1.BeginUpdate(); //记住当前焦点行索引 //int iOldHandle = this.advBandedGridView1.FocusedRowHandle; //从链表中删除 // ObjectList.Remove(obj); //刷新表格 //设置新的焦点行索引 //GridHelper.FocuseRowAfterDelete(this.advBandedGridView1, iOldHandle); //this.advBandedGridView1.EndUpdate(); } RefreshData(); //this.advBandedGridView1.EndUpdate(); }
public IList <PW_tb3a> GetList(IList <PW_tb3a> list) { IList <PW_tb3a> list2 = new List <PW_tb3a>(); for (int i = 0; i < list.Count; i++) { decimal num = 0; PW_tb3a a = list[i]; if (a.LLXMC != "") { string[] str = a.LLXMC.Split(",".ToCharArray()); for (int j = 0; j < str.Length; j++) { if (str[j] != "") { PW_tb3a pp = new PW_tb3a(); pp.LineName = str[j]; pp.col2 = Itop.Client.MIS.ProgUID; pp = (PW_tb3a)Services.BaseService.GetObject("SelectPW_tb3aByLineName", pp); if (pp != null) { num = num + (pp.SafeFH - pp.MaxFH); } } } } if (num > a.MaxFH) { a.Num1 = a.MaxFH; } else { a.Num1 = num; } a.col1 = Convert.ToDecimal(a.Num1 / a.MaxFH * 100).ToString("##.##") + "%"; if (a.Num1 / a.MaxFH * 100 < 100) { a.col2 = "否"; } else { a.col2 = "是"; } list2.Add(a); } return(list2); }
public void SubAdd() { PW_tb3a obj = FocusedObject; if (obj == null) { MessageBox.Show("请选择记录。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } FrmPW3b f = new FrmPW3b(); f.addright = f.editright = editright; f.Type = obj.UID; f.Show(); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string str = ""; if (comboBox1.Text == "局属") { str = "'局属'"; } if (comboBox1.Text == "专用") { str = "'专用'"; } if (comboBox1.Text == "全部") { str = "'局属','专用'"; } try { PW_tb3a p = new PW_tb3a(); p.col1 = str; p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy327", p); IList <PW_tb3a> list2 = new List <PW_tb3a>(); if (list.Count > 0) { PW_tb3a pp = list[0]; for (int i = 1; i < list.Count; i++) { PW_tb3a pp2 = list[i]; if (pp2.LineName == pp.LineName) { pp.LineType = pp.LineType + "," + pp2.LineType; } else { list2.Add(pp); pp = list[i]; } } list2.Add(pp); } this.gridControl.DataSource = list2; } catch (Exception e1) { MessageBox.Show(e1.Message); } }
private void FrmProject_Sum_Load(object sender, EventArgs e) { try { InitRight(); PW_tb3a p = new PW_tb3a(); p.col1 = "'局属'"; p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy322", p); this.gridControl.DataSource = SumList(list); } catch (Exception e1) { MessageBox.Show(e1.Message); } }
private void FrmProject_Sum_Load(object sender, EventArgs e) { this.gridBand5.Columns.Add(this.bandedGridColumn3); this.gridBand19.Columns.Add(this.bandedGridColumn4); InitRight(); try { PW_tb3a p = new PW_tb3a(); p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy321", p); this.gridControl.DataSource = SumList(list); } catch (Exception e1) { MessageBox.Show(e1.Message); } }
public IList <PW_tb3a> SumList(IList <PW_tb3a> _list) { IList <PW_tb3a> l = new List <PW_tb3a>(); if (_list.Count > 0) { for (int i = 0; i < _list.Count; i++) { PW_tb3a p = _list[i]; p.Num6 = p.Num6 / 10000; l.Add(p); } } return(l); }
protected bool SaveRecord() { //创建/修改 对象 try { if (IsCreate) { _obj.Num4 = _obj.Num1 + _obj.Num2 + _obj.Num3; if (_obj.SafeFH != 0) { _obj.FZL = Convert.ToDecimal(_obj.MaxFH / _obj.SafeFH * 100); } Services.BaseService.Create <PW_tb3a>(_obj); } else { PW_tb3a p1 = Services.BaseService.GetOneByKey <PW_tb3a>(_obj.UID); IList <PW_tb3a> list4 = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aByLLXName", p1); for (int i = 0; i < list4.Count; i++) { PW_tb3a p2 = list4[i]; p2.LLXMC = p2.LLXMC.Replace(p1.LineName, _obj.LineName); Services.BaseService.Update <PW_tb3a>(p2); } if (_obj.SafeFH != 0) { // _obj.FZL = Convert.ToDecimal(_obj.MaxFH / _obj.SafeFH * 100); _obj.FZL = Convert.ToDecimal(Convert.ToDecimal(_obj.MaxFH / _obj.SafeFH * 100).ToString("##.##")); } _obj.Num4 = _obj.Num1 + _obj.Num2 + _obj.Num3; Services.BaseService.Update <PW_tb3a>(_obj); } } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return(false); } //操作已成功 return(true); }
/// <summary> /// 刷新表格中的数据 /// </summary> /// <returns>ture:成功 false:失败</returns> public bool RefreshData() { try { this.advBandedGridView1.GroupPanelText = "线路设备情况表"; PW_tb3a p = new PW_tb3a(); p.col2 = proguid; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aList", p); this.gridControl.DataSource = list; } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return(false); } return(true); }
private void FrmLineSel_Load(object sender, EventArgs e) { PW_tb3a p = new PW_tb3a(); p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aListName", p); ArrayList alist = new ArrayList(); for (int i = 0; i < list.Count; i++) { if (!alist.Contains(list[i].LineName) && list[i].LineName != selfName) { alist.Add(list[i].LineName); } } for (int j = 0; j < alist.Count; j++) { checkedListBox1.Items.Add(alist[j].ToString()); } }
public IList <PW_tb3a> SumList(IList <PW_tb3a> _list) { IList <PW_tb3a> l = new List <PW_tb3a>(); if (_list.Count > 0) { PW_tb3a sum = new PW_tb3a(); sum.PQName = "市区合计"; for (int i = 0; i < _list.Count; i++) { PW_tb3a p = _list[i]; p.Num6 = p.Num6 / 10000; p.Num8 = p.Num8 / 10000; // p.MaxFH = p.MaxFH / 10000; p.SafeFH = p.SafeFH / 10000; sum.Num1 = sum.Num1 + p.Num1; sum.Num2 = sum.Num2 + p.Num2; sum.Num3 = sum.Num3 + p.Num3; sum.Num4 = sum.Num4 + p.Num4; sum.Num5 = sum.Num5 + p.Num5; sum.Num6 = sum.Num6 + p.Num6; sum.Num7 = sum.Num7 + p.Num7; sum.Num8 = sum.Num8 + p.Num8; sum.FZL = sum.FZL + p.FZL; sum.KBS = sum.KBS + p.KBS; sum.KG = sum.KG + p.KG; sum.LineLength = sum.LineLength + p.LineLength; sum.MaxFH = sum.MaxFH + p.MaxFH; sum.SafeFH = sum.SafeFH + p.SafeFH; sum.WG1 = sum.WG1 + p.WG1; sum.WG2 = sum.WG2 + p.WG2; l.Add(p); } l.Add(sum); } return(l); }
private void FrmProject_Sum_Load(object sender, EventArgs e) { InitRight(); //this.gridBand7.Columns.Add(this.bandedGridColumn7); try { PW_tb3a p = new PW_tb3a(); p.col1 = "'局属'"; p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy327", p); IList <PW_tb3a> list2 = new List <PW_tb3a>(); if (list.Count > 0) { PW_tb3a pp = list[0]; for (int i = 1; i < list.Count; i++) { PW_tb3a pp2 = list[i]; if (pp2.LineName == pp.LineName) { pp.LineType = pp.LineType + "," + pp2.LineType; } else { list2.Add(pp); pp = list[i]; } } list2.Add(pp); } this.gridControl.DataSource = list2; } catch (Exception e1) { MessageBox.Show(e1.Message); } }
//此处为动态添加数据方法 private void Sheet_AddData(FarPoint.Win.Spread.SheetView obj_sheet) { int startrow = 3; int addnum = 0; int itemcount = 0; int firstrow = 0; string rowsum = ""; string rowsum2 = ""; Itop.Domain.PWTable.PW_tb3a p = new Itop.Domain.PWTable.PW_tb3a(); p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2254", p); bool sheetEnd = false; for (int i = 0; i < list.Count; i++) { PW_tb3a obj = list[i]; PW_tb3a obj2 = new PW_tb3a(); if (i < list.Count - 1) { obj2 = list[i + 1]; } else { sheetEnd = true; } decimal _sum = obj.Num1 + obj.Num2 + obj.Num3 + obj.Num4 + obj.Num5 + obj.Num6 + obj.Num7 + obj.Num8; itemcount = itemcount + 1; obj_sheet.RowCount = obj_sheet.RowCount + 1; obj_sheet.SetValue(i + addnum + startrow, 0, obj.PQName); obj_sheet.SetValue(i + addnum + startrow, 1, "线路回数(回)"); obj_sheet.SetValue(i + addnum + startrow, 2, obj.Num1); obj_sheet.SetValue(i + addnum + startrow, 3, obj.Num2); obj_sheet.SetValue(i + addnum + startrow, 4, obj.Num3); obj_sheet.SetValue(i + addnum + startrow, 5, obj.Num4); obj_sheet.SetValue(i + addnum + startrow, 6, obj.Num5); obj_sheet.SetValue(i + addnum + startrow, 7, obj.Num6); obj_sheet.SetValue(i + addnum + startrow, 8, obj.Num7); obj_sheet.SetValue(i + addnum + startrow, 9, obj.Num8); obj_sheet.SetValue(i + addnum + startrow, 10, _sum); itemcount = itemcount + 1; addnum = addnum + 1; obj_sheet.RowCount = obj_sheet.RowCount + 1; obj_sheet.SetValue(i + addnum + startrow, 0, obj.PQName); obj_sheet.SetValue(i + addnum + startrow, 1, "所占比例(%)"); if (_sum == 0) { obj_sheet.SetValue(i + addnum + startrow, 2, "0"); obj_sheet.SetValue(i + addnum + startrow, 3, "0"); obj_sheet.SetValue(i + addnum + startrow, 4, "0"); obj_sheet.SetValue(i + addnum + startrow, 5, "0"); obj_sheet.SetValue(i + addnum + startrow, 6, "0"); obj_sheet.SetValue(i + addnum + startrow, 7, "0"); obj_sheet.SetValue(i + addnum + startrow, 8, "0"); obj_sheet.SetValue(i + addnum + startrow, 9, "0"); obj_sheet.SetValue(i + addnum + startrow, 10, "0"); } else { obj_sheet.SetValue(i + addnum + startrow, 2, Convert.ToDecimal((obj.Num1 / _sum) * 100).ToString("0.##")); obj_sheet.SetValue(i + addnum + startrow, 3, Convert.ToDecimal((obj.Num2 / _sum) * 100).ToString("0.##")); obj_sheet.SetValue(i + addnum + startrow, 4, Convert.ToDecimal((obj.Num3 / _sum) * 100).ToString("0.##")); obj_sheet.SetValue(i + addnum + startrow, 5, Convert.ToDecimal((obj.Num4 / _sum) * 100).ToString("0.##")); obj_sheet.SetValue(i + addnum + startrow, 6, Convert.ToDecimal((obj.Num5 / _sum) * 100).ToString("0.##")); obj_sheet.SetValue(i + addnum + startrow, 7, Convert.ToDecimal((obj.Num6 / _sum) * 100).ToString("0.##")); obj_sheet.SetValue(i + addnum + startrow, 8, Convert.ToDecimal((obj.Num7 / _sum) * 100).ToString("0.##")); obj_sheet.SetValue(i + addnum + startrow, 9, Convert.ToDecimal((obj.Num8 / _sum) * 100).ToString("0.##")); obj_sheet.SetValue(i + addnum + startrow, 10, "100"); } obj_sheet.AddSpanCell(i + addnum + startrow - 1, 0, 2, 1); rowsum = rowsum + Convert.ToString(startrow - 2 + 2 * (i + 1)) + ","; rowsum2 = rowsum2 + Convert.ToString(startrow - 1 + 2 * (i + 1)) + ","; if (sheetEnd) { addnum = addnum + 1; obj_sheet.RowCount = obj_sheet.RowCount + 1; obj_sheet.SetValue(i + addnum + startrow, 0, "全市合计"); obj_sheet.SetValue(i + addnum + startrow, 1, "线路回数(回)"); TC.Sheet_WriteFormula_RowSum3(obj_sheet, TC.getRowList(rowsum), 2, i + addnum + startrow, 2, 9); addnum = addnum + 1; obj_sheet.RowCount = obj_sheet.RowCount + 1; obj_sheet.SetValue(i + addnum + startrow, 0, "全市合计"); obj_sheet.SetValue(i + addnum + startrow, 1, "所占比例(%)"); //TC.Sheet_WriteFormula_TwoCol_Percent(obj_sheet, i + addnum + startrow - 1, 2, 7, 1, i + addnum + startrow, 2); obj_sheet.SetValue(i + addnum + startrow, 10, "100"); obj_sheet.AddSpanCell(i + addnum + startrow - 1, 0, 2, 1); } } }
public IList <PW_tb3a> GetList(IList <PW_tb3a> list) { IList <PW_tb3a> list2 = new List <PW_tb3a>(); for (int i = 0; i < list.Count; i++) { decimal nump = 0; PW_tb3a a = list[i]; if (a.PQName != "") { if (a.PQName.Contains("+") || a.PQName.Contains("+")) { a.PQName = a.PQName.Replace("+", "+"); string[] str = a.PQName.Split("+".ToCharArray()); for (int k = 0; k < str.Length; k++) { str[k] = str[k].Replace("×", "*"); } decimal[] num = new decimal[str.Length]; for (int n = 0; n < num.Length; n++) { num[n] = Convert.ToDecimal(new DataTable().Compute(str[n], null)); } if (num[0] > num[1]) { a.Num4 = Convert.ToDecimal(Convert.ToDouble(num[1]) * 1.235); } else { a.Num4 = Convert.ToDecimal(Convert.ToDouble(num[0]) * 1.235); } } if (a.PQName.Contains("×")) { string[] str = a.PQName.Split("×".ToCharArray()); decimal[] num = new decimal[str.Length]; for (int n = 0; n < num.Length; n++) { num[n] = Convert.ToDecimal(new DataTable().Compute(str[n], null)); } if (num[0] == 1) { a.Num4 = 0; } else { a.Num4 = Convert.ToDecimal(Convert.ToDouble(num[1]) * 1.235); } } else { a.Num4 = 0; } } else { a.Num4 = 0; } /////////////////////////////////////////////////////////////// if (a.LLXMC.Trim() != "") { string[] str = a.LLXMC.Split(",".ToCharArray()); for (int j = 0; j < str.Length; j++) { if (str[j] != "") { PW_tb3a pp = new PW_tb3a(); pp.LineName = str[j]; pp.col2 = Itop.Client.MIS.ProgUID; pp = (PW_tb3a)Services.BaseService.GetObject("SelectPW_tb3aByLineName", pp); nump = nump + (pp.SafeFH - pp.MaxFH); } } } if (nump > a.MaxFH) { a.Num6 = a.MaxFH; } else { a.Num6 = nump; } //if (a.Num3 == 0) //{ // a.col1 = "0"; //} //else //{ // a.col1 = Convert.ToDecimal((a.Num3-(a.Num4 + a.Num6)) / a.Num3 * 100).ToString("##.##") + "%"; //} //if (a.Num4 + a.Num6 > a.Num3) //{ // a.col2 = "是"; // a.col1 = "0"; //} //else //{ // if ((a.Num4 + a.Num6) / a.Num3 * 100 < 100) // { // a.col2 = "否"; // } // else // { // a.col2 = "是"; // } //} list2.Add(a); } ///////////////////////////// IList <PW_tb3a> list3 = new List <PW_tb3a>(); if (list2.Count > 0) { PW_tb3a pp = list[0]; for (int i = 1; i < list2.Count; i++) { PW_tb3a pp2 = list2[i]; if (pp2.SubName == pp.SubName) { pp.Num6 = pp.Num6 + pp2.Num6; } else { list3.Add(pp); pp = list2[i]; } } list3.Add(pp); } for (int n = 0; n < list3.Count; n++) { PW_tb3a a = list3[n]; if (a.Num3 == 0) { a.col1 = "0"; } else { a.col1 = Convert.ToDecimal((a.Num3 - (a.Num4 + a.Num6)) / a.Num3 * 100).ToString("##.##") + "%"; } if (a.Num4 + a.Num6 > a.Num3) { a.col2 = "是"; a.col1 = "0"; } else { if ((a.Num4 + a.Num6) / a.Num3 * 100 < 100) { a.col2 = "否"; } else { a.col2 = "是"; } } } return(list3); }
//此处为动态添加数据方法 private void Sheet_AddData(FarPoint.Win.Spread.SheetView obj_sheet) { int startrow = 3; int addnum = 0; int itemcount = 0; int firstrow = 0; ArrayList rowsum = new ArrayList(); Itop.Domain.PWTable.PW_tb3a p = new Itop.Domain.PWTable.PW_tb3a(); p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> list = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2251", p); PW_tb3c p3 = new PW_tb3c(); p3.col4 = Itop.Client.MIS.ProgUID; IList <PW_tb3c> plist = Services.BaseService.GetList <PW_tb3c>("SelectPW_tb3cList", p3); IList <PW_tb3a> alist = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aListDIS", p); for (int n = 0; n < plist.Count; n++) { rowsum.Add(""); } bool sheetEnd = false; for (int i = 0; i < list.Count; i++) { PW_tb3a obj = list[i]; PW_tb3a obj2 = new PW_tb3a(); if (i < list.Count - 1) { obj2 = list[i + 1]; } else { sheetEnd = true; } itemcount = itemcount + 1; obj_sheet.RowCount = obj_sheet.RowCount + 1; obj_sheet.SetValue(i + addnum + startrow, 0, obj.PQName); obj_sheet.SetValue(i + addnum + startrow, 1, obj.PQtype); obj_sheet.SetValue(i + addnum + startrow, 2, obj.Num10); obj_sheet.SetValue(i + addnum + startrow, 3, obj.Num3); obj_sheet.SetValue(i + addnum + startrow, 4, obj.Num2); obj_sheet.SetValue(i + addnum + startrow, 5, obj.Num4); obj_sheet.SetValue(i + addnum + startrow, 6, obj.KggNum); obj_sheet.SetValue(i + addnum + startrow, 7, obj.KG); obj_sheet.SetValue(i + addnum + startrow, 8, obj.KgzHwNum); obj_sheet.SetValue(i + addnum + startrow, 9, obj.Num11); // obj_sheet.SetValue(i + 3, 10, 1); if (obj.PQName != obj2.PQName) { addnum = addnum + 1; for (int x = 0; x < rowsum.Count; x++) { string str = (string)rowsum[x]; str = str + Convert.ToString(i + addnum + startrow - x - 1) + ","; rowsum[x] = str; } obj_sheet.RowCount = obj_sheet.RowCount + 1; obj_sheet.SetValue(i + addnum + startrow, 0, obj.PQName); obj_sheet.SetValue(i + addnum + startrow, 1, "小计"); int num1 = startrow + addnum + firstrow; if (firstrow == 0) { num1 = num1 - 1; } TC.Sheet_WriteFormula_RowSum(obj_sheet, num1, 2, itemcount, 1, i + addnum + startrow, 2, 8); obj_sheet.AddSpanCell(num1, 0, itemcount + 1, 1); firstrow = i; startrow = 3; itemcount = 0; } if (sheetEnd) { int[] sum = new int[plist.Count]; rowsum.Reverse(); for (int m = 0; m < plist.Count; m++) { PW_tb3c _p = plist[m]; addnum = addnum + 1; obj_sheet.RowCount = obj_sheet.RowCount + 1; obj_sheet.SetValue(i + addnum + startrow, 0, "全市合计"); obj_sheet.SetValue(i + addnum + startrow, 1, _p.col1); sum[m] = i + addnum + startrow; int num1 = startrow + addnum + firstrow; //if (firstrow == 0) { num1 = num1 - 1; } TC.Sheet_WriteFormula_RowSum3(obj_sheet, TC.getRowList(rowsum[m].ToString()), 2, i + addnum + startrow, 2, 8); } addnum = addnum + 1; obj_sheet.RowCount = obj_sheet.RowCount + 1; obj_sheet.SetValue(i + addnum + startrow, 0, "全市合计"); obj_sheet.SetValue(i + addnum + startrow, 1, "总计"); TC.Sheet_WriteFormula_RowSum3(obj_sheet, sum, 2, i + addnum + startrow, 2, 8); obj_sheet.AddSpanCell(sum[0], 0, sum.Length + 1, 1); } } }
private void InsertInfo() { string columnname = ""; try { DataTable dts = new DataTable(); OpenFileDialog op = new OpenFileDialog(); op.Filter = "Excel文件(*.xls)|*.xls"; if (op.ShowDialog() == DialogResult.OK) { dts = GetExcel(op.FileName); IList <PW_tb3a> lii = new List <PW_tb3a>(); DateTime s8 = DateTime.Now; for (int i = 0; i < dts.Rows.Count; i++) { PW_tb3a l1 = new PW_tb3a(); foreach (DataColumn dc in dts.Columns) { columnname = dc.ColumnName; //if (dts.Rows[i][dc.ColumnName].ToString() == "") // continue; switch (dc.ColumnName) { case "LineLength": case "Num1": case "Num2": case "Num3": case "Num4": case "Num6": case "Num8": case "MaxFH": case "SafeFH": case "WG1": case "WG2": case "FZL": decimal LL2 = 0; try { LL2 = Convert.ToDecimal(dts.Rows[i][dc.ColumnName].ToString()); } catch { } l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, LL2, null); break; case "Num5": case "Num7": case "KBS": case "KG": int l5 = 0; try { l5 = Convert.ToInt32(dts.Rows[i][dc.ColumnName].ToString()); } catch { } l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, l5, null); break; default: l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, dts.Rows[i][dc.ColumnName].ToString(), null); break; } } lii.Add(l1); } foreach (PW_tb3a lll in lii) { PW_tb3a l1 = new PW_tb3a(); IList <PW_tb3a> list = new List <PW_tb3a>(); //if (type == "2") //{ // l1.S1 = lll.S1; // l1.T1 = lll.T1; // l1.T5 = lll.T5; // l1.S5 = type; // list = Common.Services.BaseService.GetList<Project_Sum>("SelectProject_SumByvalue3", l1); //} //if (list.Count > 0) //{ // lll.UID = list[0].UID; // Services.BaseService.Update<PW_tb3a>(lll); //} //else //{ lll.UID = Guid.NewGuid().ToString(); lll.col2 = Itop.Client.MIS.ProgUID; Services.BaseService.Create <PW_tb3a>(lll); //} } this.ctrlProject_Sum1.RefreshData(); } } catch (Exception ex) { MsgBox.Show(columnname + ex.Message); MsgBox.Show("导入格式不正确!"); } }
//此处为动态添加数据方法 private void Sheet_AddData(FarPoint.Win.Spread.SheetView obj_sheet) { int startrow = 2; int addnum = 0; int itemcount = 0; int firstrow = 0; ArrayList rowsum = new ArrayList(); Itop.Domain.PWTable.PW_tb3a p = new Itop.Domain.PWTable.PW_tb3a(); p.col2 = Itop.Client.MIS.ProgUID; IList <PW_tb3a> alist = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aListDIS", p); for (int n = 0; n < alist.Count; n++) { for (int m = 0; m < 8; m++) { obj_sheet.RowCount = obj_sheet.RowCount + 1; } obj_sheet.AddSpanCell(2, 0, 8, 1); obj_sheet.SetValue(2, 0, "XX区(县)"); //2列标题内容 obj_sheet.AddSpanCell(startrow + n * 8, 1, 6, 1); obj_sheet.SetValue(startrow + n * 8, 1, "典型接线(回)"); obj_sheet.AddSpanCell(startrow + (n + 1) * 8 - 1, 1, 1, 2); obj_sheet.SetValue(startrow + (n + 1) * 8 - 1, 1, "辐射型"); obj_sheet.AddSpanCell(startrow + (n + 1) * 8, 1, 1, 2); obj_sheet.SetValue(startrow + (n + 1) * 8, 1, "其他非典型接线(回)"); //3列标题内容 obj_sheet.SetValue(startrow + n * 8, 2, "两供一备"); obj_sheet.SetValue(startrow + n * 8 + 1, 2, "三供一备"); obj_sheet.SetValue(startrow + n * 8 + 2, 2, "单环网"); obj_sheet.SetValue(startrow + n * 8 + 3, 2, "双环网"); obj_sheet.SetValue(startrow + n * 8 + 4, 2, "多分段两联络"); obj_sheet.SetValue(startrow + n * 8 + 5, 2, "多分段三联络"); PW_tb3a _tba = alist[n]; p.PQName = _tba.PQName; p.JXMS = "两供一备"; IList <PW_tb3a> list1 = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2255", p); p.JXMS = "三供一备"; IList <PW_tb3a> list2 = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2255", p); p.JXMS = "单环网"; IList <PW_tb3a> list3 = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2255", p); p.JXMS = "双环网"; IList <PW_tb3a> list4 = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2255", p); p.JXMS = "多分段两联络"; IList <PW_tb3a> list5 = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2255", p); p.JXMS = "多分段三联络"; IList <PW_tb3a> list6 = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2255", p); p.JXMS = "辐射型"; IList <PW_tb3a> list7 = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2255", p); p.JXMS = "其他非典型接线"; IList <PW_tb3a> list8 = Services.BaseService.GetList <PW_tb3a>("SelectPW_tb3aBy2255", p); if (list1.Count > 0) { PW_tb3a obj = list1[0]; obj_sheet.SetValue(n + startrow + n * 7, 0, obj.PQName); obj_sheet.SetValue(n + startrow + n * 7, 3, obj.Num1); obj_sheet.SetValue(n + startrow + n * 7, 4, obj.Num2); obj_sheet.SetValue(n + startrow + n * 7, 5, obj.Num3); obj_sheet.SetValue(n + startrow + n * 7, 6, obj.Num4); obj_sheet.SetValue(n + startrow + n * 7, 7, obj.Num5); obj_sheet.SetValue(n + startrow + n * 7, 8, obj.Num6); obj_sheet.SetValue(n + startrow + n * 7, 9, obj.Num7); obj_sheet.SetValue(n + startrow + n * 7, 10, obj.Num8); } else { TC.Sheet_WriteZero(obj_sheet, n + startrow + n * 7, 3, 1, 8); } } }