//删除 private void simpleButton4_Click(object sender, EventArgs e) { if (gridView1.FocusedRowHandle < 0) { MessageBox.Show("请选择一条记录!"); return; } string id = this.gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID").ToString(); Ps_Table_Edit edit = Common.Services.BaseService.GetOneByKey <Ps_Table_Edit>(id); if (edit.Status == "扩建/改造" || edit.Status == "拆除") { if (MessageBox.Show("确定删除这条记录吗?", "删除", MessageBoxButtons.YesNo) == DialogResult.Yes) { Common.Services.BaseService.Delete <Ps_Table_Edit>(edit); string conn = "ParentID='" + parentid + "'"; list = Common.Services.BaseService.GetList <Ps_Table_Edit>("SelectPs_Table_EditListByConn", conn); LoadGridData(); label7.Text = GetCurVolumn(); if (typeTable == "500") { Ps_Table_500PH table = new Ps_Table_500PH(); table = Common.Services.BaseService.GetOneByKey <Ps_Table_500PH>(parentid); if (comboBoxEdit1.Text == "扩建/改造") { string a = table.GetType().GetProperty("y" + comboBoxEdit3.Text).GetValue(table, null).ToString(); for (int i = int.Parse(comboBoxEdit3.Text); i <= yearRange.FinishYear; i++) { 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 == "扩建/改造") { string a = table.GetType().GetProperty("y" + comboBoxEdit3.Text).GetValue(table, null).ToString(); for (int i = int.Parse(comboBoxEdit3.Text); i <= yearRange.FinishYear; i++) { 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 == "扩建/改造") { string a = table.GetType().GetProperty("y" + comboBoxEdit3.Text).GetValue(table, null).ToString(); for (int i = int.Parse(comboBoxEdit3.Text); i <= yearRange.FinishYear; i++) { table.GetType().GetProperty("y" + i.ToString()).SetValue(table, Convert.ToDouble(a) - Convert.ToDouble(spinEdit1.Text), null); } Common.Services.BaseService.Update("UpdatePs_Table_100PH", table); } } } } else { MessageBox.Show("只能删除扩建/改造或拆除的记录。"); } }
public string GetCurVolumn() { Ps_YearRange range = yearRange; string conn = "ParentID='" + parentid + "'"; IList tList = Common.Services.BaseService.GetList("SelectPs_Table_EditListByConn", conn); if (typeTable == "500") { Ps_Table_500PH edit = Common.Services.BaseService.GetOneByKey <Ps_Table_500PH>(parentid); for (int j = 0; j < tList.Count; j++) { if (((Ps_Table_Edit)tList[j]).Status == "扩建/改造") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { double old = (double)edit.GetType().GetProperty("y" + k.ToString()).GetValue(edit, null); edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, double.Parse(((Ps_Table_Edit)tList[j]).Volume) + old, null); } } else if (((Ps_Table_Edit)tList[j]).Status == "拆除") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, 0.0, null); } } } return(edit.GetType().GetProperty("y" + range.EndYear).GetValue(edit, null).ToString()); } else if (typeTable == "200") { Ps_Table_200PH edit = Common.Services.BaseService.GetOneByKey <Ps_Table_200PH>(parentid); for (int j = 0; j < tList.Count; j++) { if (((Ps_Table_Edit)tList[j]).Status == "扩建/改造") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { double old = (double)edit.GetType().GetProperty("y" + k.ToString()).GetValue(edit, null); edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, double.Parse(((Ps_Table_Edit)tList[j]).Volume) + old, null); } } else if (((Ps_Table_Edit)tList[j]).Status == "拆除") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, 0.0, null); } } } return(edit.GetType().GetProperty("y" + range.EndYear).GetValue(edit, null).ToString()); } else if (typeTable == "100") { Ps_Table_100PH edit = Common.Services.BaseService.GetOneByKey <Ps_Table_100PH>(parentid); for (int j = 0; j < tList.Count; j++) { if (((Ps_Table_Edit)tList[j]).Status == "扩建/改造") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { double old = (double)edit.GetType().GetProperty("y" + k.ToString()).GetValue(edit, null); edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, double.Parse(((Ps_Table_Edit)tList[j]).Volume) + old, null); } } else if (((Ps_Table_Edit)tList[j]).Status == "拆除") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, 0.0, null); } } } return(edit.GetType().GetProperty("y" + range.EndYear).GetValue(edit, null).ToString()); } else if (typeTable == "35") { Ps_Table_35PH edit = Common.Services.BaseService.GetOneByKey <Ps_Table_35PH>(parentid); for (int j = 0; j < tList.Count; j++) { if (((Ps_Table_Edit)tList[j]).Status == "扩建/改造") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { double old = (double)edit.GetType().GetProperty("y" + k.ToString()).GetValue(edit, null); edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, double.Parse(((Ps_Table_Edit)tList[j]).Volume) + old, null); } } else if (((Ps_Table_Edit)tList[j]).Status == "拆除") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, 0.0, null); } } } return(edit.GetType().GetProperty("y" + range.EndYear).GetValue(edit, null).ToString()); } else { Ps_PowerBuild edit = Common.Services.BaseService.GetOneByKey <Ps_PowerBuild>(parentid); for (int j = 0; j < tList.Count; j++) { if (((Ps_Table_Edit)tList[j]).Status == "扩建/改造") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { double old = (double)edit.GetType().GetProperty("y" + k.ToString()).GetValue(edit, null); edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, double.Parse(((Ps_Table_Edit)tList[j]).Volume) + old, null); } } else if (((Ps_Table_Edit)tList[j]).Status == "拆除") { for (int k = int.Parse(((Ps_Table_Edit)tList[j]).FinishYear); k <= range.EndYear; k++) { edit.GetType().GetProperty("y" + k.ToString()).SetValue(edit, 0.0, null); } } } return(edit.GetType().GetProperty("y" + range.EndYear).GetValue(edit, null).ToString()); } }
//增加 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(); }