public void LoadData() { PSP_interface p = new PSP_interface(); p = Services.BaseService.GetOneByKey<PSP_interface>(uid); if (p != null) { bdz = p.BdzId; fq = p.FQId; fxt = p.FxtId; bdzlist = bdz.Split(",".ToCharArray()); fqlist = fq.Split(",".ToCharArray()); fxtlist = fxt.Split(",".ToCharArray()); } object[] obj = new object[30]; for (int i = 0; i < 30; i++) { obj[i] = 2000 + i; } this.year.Properties.Items.AddRange(obj); }
/// <summary> /// ɾ��������� /// </summary> public void DeleteObject() { //��ȡ������� PSP_interface obj = FocusedObject; if (obj == null) { return; } //����ȷ�� if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes) { return; } //ִ��ɾ������ try { int[] l = gridView.GetSelectedRows(); for (int i = 0; i < l.Length;i++ ) { PSP_interface p_obj = gridView.GetRow(l[i]) as PSP_interface; PSP_interface p = new PSP_interface(); p.UID = p_obj.UID; p =(PSP_interface) Services.BaseService.GetObject("SelectPSP_interfaceByKey", p); if (p != null) { p.BdzId = p.BdzId.Replace(typeid, ""); if (p.BdzId.Length < 20) { Services.BaseService.Delete<PSP_interface>(p); } else { Services.BaseService.Update<PSP_interface>(p); } } } this.gridView.BeginUpdate(); //��ס��ǰ���������� int iOldHandle = this.gridView.FocusedRowHandle; //��������ɾ�� //ObjectList.Remove(p_obj); //ˢ�±�� gridView.DeleteSelectedRows(); gridControl.RefreshDataSource(); //�����µĽ��������� //GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle); this.gridView.EndUpdate(); } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return; } }
protected override void Del() { if (!DeleteRight) { MessageBox.Show("��û�д�Ȩ�ޡ�", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSP_interface ins = new PSP_interface(); ins.col1 = " BdzId like '%"+treeView1.SelectedNode.Tag.ToString()+"%' "; IList<PSP_interface> l2 = Services.BaseService.GetList<PSP_interface>("SelectPSP_interfaceByWhere", ins); if(l2.Count>0){ MessageBox.Show("�����°������ݣ�����ɾ����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if(treeView1.SelectedNode.Nodes.Count>0){ MessageBox.Show("�����°����ӷ��࣬����ɾ����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("ȷ��ɾ��ô?", "��ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { PSP_bdz_type p = new PSP_bdz_type(); p.id = treeView1.SelectedNode.Tag.ToString(); Services.BaseService.Update("DeletePSP_bdz_type", p); treeView1.Nodes.Remove(treeView1.SelectedNode); ctrlLineType1.Typeid = typeid; ctrlLineType1.RefreshData(); } }
//public DataSet GetDataSet(string cmd) //{ // this.CheckConnection(); // DataSet dataSet = new DataSet(); // try // { // OracleCommand dataCommand = new OracleCommand(cmd, con); // OracleDataAdapter dataAdapter = new OracleDataAdapter(); // dataAdapter.SelectCommand = dataCommand; // dataAdapter.Fill(dataSet, "recordSet"); // } // catch (Exception se) // { // throw new Exception("Error in SQL", se); // } // finally // { // closeConn(); // } // return dataSet; //} private void simpleButton3_Click(object sender, EventArgs e) { if (ctrlglebeType1.GridView.GetSelectedRows() == null || ctrlglebeType1.GridView.GetSelectedRows().Length < 1) { MessageBox.Show("��ѡ���¼��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (Treeid=="") { MessageBox.Show("��ָ��һ������ķ��ࡣ", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //if (lookUpEdit2.Text == "") //{ // MessageBox.Show("��ָ��Ҫ���뵽�ķ�����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //if (lookUpEdit3.Text == "") //{ // MessageBox.Show("��ָ��Ҫ���뵽�ķ�ϵͳ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} IList<PSP_interface> list_temp =ctrlglebeType1.GridControl.DataSource as IList<PSP_interface>; int[] l=ctrlglebeType1.GridView.GetSelectedRows(); for (int i = 0; i < l.Length;i++ ) { PSP_interface p = ctrlglebeType1.GridView.GetRow(l[i]) as PSP_interface; p.BdzId = treeView1.SelectedNode.Tag.ToString(); //p.FQId = lookUpEdit2.EditValue.ToString(); //p.FxtId = lookUpEdit3.EditValue.ToString(); PSP_interface p2 = new PSP_interface(); p2.col1 = " UYear='" + p.UYear + "' and UMonth='" + p.UMonth + "' and Substation_Name='" + p.Substation_Name + "' and Switch_Id='"+p.Switch_Id+"' "; p2 =(PSP_interface) Services.BaseService.GetObject("SelectPSP_interfaceByWhere", p2); if (p2 != null) { if(!p2.BdzId.Contains(p.BdzId)){ p2.BdzId = p2.BdzId + "," + p.BdzId; } //if (!p2.FQId.Contains(p.FQId)) //{ // p2.FQId = p2.FQId + "," + p.FQId; //} //if (!p2.FxtId.Contains(p.FxtId)) //{ // p2.FxtId = p2.FxtId + "," + p.FxtId; //} Services.BaseService.Update<PSP_interface>(p2); } else { Services.BaseService.Create<PSP_interface>(p); } } MessageBox.Show("����ɹ���", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void simpleButton2_Click(object sender, EventArgs e) { //simpleButton3.Enabled = false; if(treeView1.SelectedNode==null){ MessageBox.Show("��ѡ����ࡣ", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string sql=" 1=1 "; if (treeView1.SelectedNode.Tag.ToString() != "0") { sql = sql + " and BdzId like '%" + treeView1.SelectedNode.Tag.ToString() + "%'"; } //if (lookUpEdit2.Text != "") //{ // sql = sql + " and FQId like '%" + lookUpEdit2.EditValue + "%'"; //} //if (lookUpEdit3.Text != "") //{ // sql = sql + " and FxtId like '%" + lookUpEdit3.EditValue + "%'"; //} if(year.Text!=""){ sql = sql + " and UYear=" + year.Text; } if(month.Text!="ȫ��"){ sql = sql + " and UMonth=" + month.Text; } sql = sql + " order by UYear,UMonth,Substation_Name,Switch_Id"; PSP_interface p2 = new PSP_interface(); p2.col1 = sql; IList<PSP_interface> list2 = Services.BaseService.GetList<PSP_interface>("SelectPSP_interfaceByWhere", p2); ctrlglebeType1.GridControl.DataSource = list2; }
//private static IOraService oraService; //public static IOraService OraService //{ // get // { // if (oraService == null) // { // oraService = RemotingHelper.GetRemotingService<IOraService>(); // } // if (oraService == null) MsgBox.Show("����û��ע��"); // return OraService; // } //} private void simpleButton1_Click(object sender, EventArgs e) { IOraService OraService = RemotingHelper.GetRemotingService<IOraService>(); try { FlashWindow frmLoad = new FlashWindow(); //f.SetText("��������ȴ���"); frmLoad.Show(); frmLoad.RefleshStatus("��������ȴ�..."); //Application.DoEvents(); frmLoad.SplashData(); string str_sql = ""; string selYear = year.Text; string selMonth = month.Text; string StartDate = ""; string EndDate = ""; IList list2 = new List<PSP_interface>(); if (selMonth != "ȫ��") { StartDate = selYear + "-" + selMonth + "-01 00:00:00"; EndDate = selYear + "-" + selMonth + "-31 23:59:59"; str_sql = "select c.name,b.code,b.name,sum(case a.power_Type when 10 then a.total_value else 0 end),sum(case a.power_Type when 11 then a.total_value else 0 end) from mp_day_e" + selYear + " a,switch b,substation c " + "where b.substation_id=c.id and b.id=a.mp_id and (a.power_Type='10' or a.power_Type='11') and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate + "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name"; //con = GetConn(); DataSet d = OraService.GetDataSet(str_sql, connstr); // GetDataSet(str_sql); for (int i = 0; i < d.Tables[0].Rows.Count; i++) { PSP_interface p = new PSP_interface(); p.UMonth = month.Text; p.UYear = Convert.ToInt32(year.Text); if (Convert.IsDBNull(d.Tables[0].Rows[i][3])) { p.Number = 0; } else { p.Number =Convert.ToDouble(Math.Round( Convert.ToDouble(d.Tables[0].Rows[i][3])/10000,2)); } if (Convert.IsDBNull(d.Tables[0].Rows[i][4])) { p.col1 = "0"; } else { p.col1 =Convert.ToString(Math.Round( Convert.ToDouble(d.Tables[0].Rows[i][4])/10000,2)); } p.Substation_Name = d.Tables[0].Rows[i][0].ToString(); p.Switch_Id = d.Tables[0].Rows[i][1].ToString(); p.Switch_Name = d.Tables[0].Rows[i][2].ToString(); p.UID = Guid.NewGuid().ToString(); list2.Add(p); } str_sql = "select c.name,b.code,b.name,sum(a.value) from mp_measure" + selYear +selMonth+ " a,switch b,substation c " + "where b.substation_id=c.id and b.id=a.mp_id and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate + "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name"; DataSet d2 = OraService.GetDataSet(str_sql, connstr); for (int i = 0; i < d2.Tables[0].Rows.Count; i++) { PSP_interface p = new PSP_interface(); //p.UMonth = month.Text; //p.UYear = Convert.ToInt32(year.Text); //if (Convert.IsDBNull(d.Tables[0].Rows[i][3])) //{ // p.Number = 0; //} //else //{ // p.Number = Convert.ToDouble(d.Tables[0].Rows[i][3]); //} if (Convert.IsDBNull(d2.Tables[0].Rows[i][3])) { p.LoadValue = 0; } else { p.LoadValue = Convert.ToDouble(Math.Round(Convert.ToDouble(d2.Tables[0].Rows[i][3]),2)); } //p.Substation_Name = d.Tables[0].Rows[i][0].ToString(); //p.Switch_Id = d.Tables[0].Rows[i][1].ToString(); //p.Switch_Name = d.Tables[0].Rows[i][2].ToString(); //p.UID = Guid.NewGuid().ToString(); ((PSP_interface)list2[i]).LoadValue = p.LoadValue; ; } ctrlglebeType1.GridControl.DataSource = list2; } else { try { for (int n = 1; n < 13; n++) { string mm = n.ToString(); if (mm.Length < 2) { mm = "0" + mm; } StartDate = selYear + "-" + mm + "-01 00:00:00"; EndDate = selYear + "-" + mm + "-31 23:59:59"; str_sql = "select c.name,b.code,b.name,sum(case a.power_Type when 10 then a.total_value else 0 end),sum(case a.power_Type when 11 then a.total_value else 0 end) from mp_day_e" + selYear + " a,switch b,substation c " + "where b.substation_id=c.id and b.id=a.mp_id and (a.power_Type='10' or a.power_Type='11') and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate + "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name"; //con = GetConn(); DataSet d = OraService.GetDataSet(str_sql, connstr); for (int i = 0; i < d.Tables[0].Rows.Count; i++) { PSP_interface p = new PSP_interface(); p.UMonth = mm; p.UYear = Convert.ToInt32(year.Text); if (Convert.IsDBNull(d.Tables[0].Rows[i][3])) { p.Number = 0; } else { p.Number = Convert.ToDouble(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][3])/10000,2)); } if (Convert.IsDBNull(d.Tables[0].Rows[i][4])) { p.col1 = "0"; } else { p.col1 = Convert.ToString(Math.Round(Convert.ToDouble(d.Tables[0].Rows[i][4]) / 10000, 2)); } p.Substation_Name = d.Tables[0].Rows[i][0].ToString(); p.Switch_Id = d.Tables[0].Rows[i][1].ToString(); p.Switch_Name = d.Tables[0].Rows[i][2].ToString(); p.UID = Guid.NewGuid().ToString(); list2.Add(p); } str_sql = "select c.name,b.code,b.name,sum(a.value) from mp_measure" + selYear +mm+ " a,switch b,substation c " + "where b.substation_id=c.id and b.id=a.mp_id and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')>='" + StartDate + "' and TO_CHAR(a.datetime/(24*3600) + TO_DATE('1970-1-1 08:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')<='" + EndDate + "' group by c.name,b.code,b.name"; //con = GetConn(); DataSet d2 = OraService.GetDataSet(str_sql, connstr); for (int i = 0; i < d2.Tables[0].Rows.Count; i++) { PSP_interface p = new PSP_interface(); //p.UMonth = mm; //p.UYear = Convert.ToInt32(year.Text); //if (Convert.IsDBNull(d.Tables[0].Rows[i][3])) //{ // p.Number = 0; //} //else //{ // p.Number = Convert.ToDouble(d.Tables[0].Rows[i][3]); //} if (Convert.IsDBNull(d2.Tables[0].Rows[i][3])) { p.LoadValue = 0; } else { p.LoadValue = Convert.ToDouble(Math.Round(Convert.ToDouble(d2.Tables[0].Rows[i][3]),2)); } //p.Substation_Name = d.Tables[0].Rows[i][0].ToString(); //p.Switch_Id = d.Tables[0].Rows[i][1].ToString(); //p.Switch_Name = d.Tables[0].Rows[i][2].ToString(); //p.UID = Guid.NewGuid().ToString(); ((PSP_interface)list2[i]).LoadValue=p.LoadValue; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { ctrlglebeType1.GridControl.DataSource = list2; } } if (list2.Count > 0) { } else { } frmLoad.Close(); } catch(Exception e1){ MessageBox.Show("û���ҵ������Ϣ��������ѡ��ʱ�䡣"+e1.Message, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); } }