private void barDel1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            GridColumn gc = this.ctrlItemPlanTable_HuaiBei1.GridView.FocusedColumn;
               if (gc == null)
               return;

               if (gc.FieldName.Substring(0, 1) != "S")
               {
               MsgBox.Show("����ɾ���̶���");
               return;
               }
               bool bl = false;
               for (int i = 0; i < ctrlItemPlanTable_HuaiBei1.GridView.VisibleColumns.Count; i++)
            {
                if (gc.Caption == ctrlItemPlanTable_HuaiBei1.GridView.VisibleColumns[i].Caption)
                {
                    if (MsgBox.ShowYesNo("�Ƿ�ɾ�� " + gc.Caption + " ���������ݣ�") != DialogResult.Yes)
                    {
                        return;
                    }
                    bl = true;
                    break;
                }
                else
                {
                    bl = false;
                }

            }
            if (bl == true)
            {
                int colIndex = ctrlItemPlanTable_HuaiBei1.GridView.FocusedColumn.VisibleIndex;

                foreach (GridBand gc1 in ctrlItemPlanTable_HuaiBei1.bandedGridView1.Bands)
                {
                    try
                    {
                        if (gc1.Columns[0].Name == gc.Name)
                        {
                            gc1.Visible = false;
                        }
                    }
                    catch { }
                }

                gc.Visible = false;
                gc.OptionsColumn.ShowInCustomizationForm = false;
                PSP_PlanTable_HuaiBei si = new PSP_PlanTable_HuaiBei();
                si.Title = gc.FieldName + "=''";
                si.Flag2 = flag;
                Itop.Client.Common.Services.BaseService.Update("UpdatePSP_PlanTable_HuaiBeiByFlag", si);

                PowerSubstationLine psl = new PowerSubstationLine();
                psl.ClassType = gc.FieldName;
                psl.Flag = flag;
                psl.Type = type;
                psl.Title = gc.Caption;
                psl.Type2 = "PlanTable";
                Itop.Client.Common.Services.BaseService.Update("DeletePowerSubstationLineByAll", psl);

                if (colIndex >= ctrlItemPlanTable_HuaiBei1.GridView.VisibleColumns.Count)
                {
                    colIndex--;
                }
                ctrlItemPlanTable_HuaiBei1.GridView.FocusedColumn = ctrlItemPlanTable_HuaiBei1.GridView.VisibleColumns[colIndex];

            }
            else
            {
                return;
            }
        }
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            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<PSP_PlanTable_HuaiBei> lii = new List<PSP_PlanTable_HuaiBei>();

                    DateTime dt= DateTime.Now;
                    for (int i =0; i < dts.Rows.Count; i++)
                    {
                        PSP_PlanTable_HuaiBei li = new PSP_PlanTable_HuaiBei();

                         //   li.Title = dts.Rows[i][0].ToString();

                            li.Flag = typeflag;
                            li.UID = Guid.NewGuid().ToString();
                            li.CreateDate = dt.AddSeconds(i);
                            li.ParentID = ctrlItemPlanTable_HuaiBei1.FocusedObject.DY;
                           // li.S1 = dts.Rows[i][1].ToString();

                            foreach (DataColumn dc in dts.Columns)
                            {
                                columnname = dc.ColumnName;
                                if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                    continue;

                                string LL2 = "";
                                try
                                {
                                    LL2 = dts.Rows[i][dc.ColumnName].ToString();
                                }
                                catch { }
                                li.GetType().GetProperty(dc.ColumnName).SetValue(li, LL2, null);

                            }

                            lii.Add(li);

                    }

                    foreach (PSP_PlanTable_HuaiBei lll in lii)
                    {
                        Services.BaseService.Create<PSP_PlanTable_HuaiBei>(lll);

                    }

                    this.ctrlItemPlanTable_HuaiBei1.RefreshData1();

                }
            }
            catch { MessageBox.Show(columnname+"�����ʽ����ȷ��"); }
        }
        //private IList<PSP_PlanTable_HuaiBei> tablelist(DataSet ds)
        //{
        //    PSP_PlanTable_HuaiBei t = default(PSP_PlanTable_HuaiBei);
        //    ds.Tables[0].TableName = typeof(T).Name;
        //    string str = ds.GetXml();
        //    XmlDocument xd = new XmlDocument();
        //    xd.LoadXml(str);
        //    XmlNodeList xls = xd.SelectNodes("/" + typeof(PSP_PlanTable_HuaiBei).Name.ToString() + "s/" + typeof(PSP_PlanTable_HuaiBei).Name.ToString());
        //    IList<PSP_PlanTable_HuaiBei> ts = new List<PSP_PlanTable_HuaiBei>();
        //    foreach (XmlNode xn in xls)
        //    {
        //        string str1 = xn.OuterXml;
        //        System.Xml.Serialization.XmlSerializer xms = new XmlSerializer(typeof(PSP_PlanTable_HuaiBei));
        //        System.IO.MemoryStream m = new System.IO.MemoryStream();
        //        System.IO.StreamWriter sw = new System.IO.StreamWriter(m);
        //        sw.Write(str1);
        //        sw.Flush();
        //        m.Position = 0;
        //        t = (PSP_PlanTable_HuaiBei)xms.Deserialize(m);
        //        ts.Add(t);
        //    }
        //    if (null != ts)
        //        return ts;
        //    else
        //        return null;
        //}
        /// <summary>
        /// ��Ӷ���
        /// </summary>
        public void AddObject(string flag)
        {
            // �����������Ƿ��Ѿ�����
            if (ObjectList == null)
            {
                return;
            }
            //�½�����
            PSP_PlanTable_HuaiBei obj = new PSP_PlanTable_HuaiBei();

            obj.Flag2 = flags1;
            obj.CreateDate = DateTime.Now;

            //ִ����Ӳ���
            using (FrmPSP_PlanTable_HuaiBeiDialog dlg = new FrmPSP_PlanTable_HuaiBeiDialog())
            {
                dlg.Type = types1;
                dlg.Flag = flags1;
                dlg.Type2 = types2;
               //// dlg.ctrlPSP_PowerSubstationInfo = this;
                dlg.Text = "�����Ŀ�ƻ���";
                dlg.IsCreate = true;    //�����½���־
                dlg.Object = obj;

                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //���¶�����뵽������
            ObjectList.Add(obj);

            //ˢ�±�񣬲��������ж�λ���¶����ϡ�
            gridControl.RefreshDataSource();
            RefreshData1();
            GridHelper.FocuseRow(this.bandedGridView1, obj);
        }
        /// <summary>
        /// �޸Ľ������
        /// </summary>
        public void UpdateObject()
        {
            //��ȡ�������
            PSP_PlanTable_HuaiBei obj = FocusedObject;
            if (obj == null)
            {
                return;
            }

            //���������һ������
            PSP_PlanTable_HuaiBei objCopy = new PSP_PlanTable_HuaiBei();
            DataConverter.CopyTo<PSP_PlanTable_HuaiBei>(obj, objCopy);

            //ִ���޸IJ���
            using (FrmPSP_PlanTable_HuaiBeiDialog dlg = new FrmPSP_PlanTable_HuaiBeiDialog())
            {
                dlg.IsSelect = isselect;
                dlg.Type = types1;
                dlg.Flag = flags1;
                dlg.Type2 = types2;
                dlg.Text = "�޸���Ŀ�ƻ���";
               //// dlg.ctrlPSP_PowerSubstationInfo = this;
                //int[] a = this.GridView.SetFocusedRowCellValue(.GetSelectedRows(); //����ʵ�����ȥ ��ȡѡ�е���
                //LAA.AssetGuid = this.GridView.GetRowCellValue(a[0], ).ToString();//��ȡѡ���е�����

                dlg.Object = objCopy;   //�󶨸���
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //�ø������½������
            DataConverter.CopyTo<PSP_PlanTable_HuaiBei>(objCopy, obj);
            //ˢ�±��
            RefreshData1();
            gridControl.RefreshDataSource();
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if(textEdit1.Text == string.Empty)
            {
                MsgBox.Show("������ƻ������ƣ�");
                return;
            }
            if (dateEdit1.Text == string.Empty)
            {
                MsgBox.Show("�����뽨��ʱ�䣡");
                return;
            }
            if(_isEdit)//�޸�
            {

            }
            else//�½�
            {
                psp_ForecastReport = new PowerEachList();
                psp_ForecastReport.Types= _typeFlag;
            }
            psp_ForecastReport.ListName = textEdit1.Text;
            DateTime dt = DateTime.Now;
            //if (dateEdit1.Text == "")
            //    dateEdit1.Text = dt;
            if (Convert.ToDateTime(dateEdit1.Text) > dt)
            {
                psp_ForecastReport.CreateDate = dt;
            }
            else
            {
                psp_ForecastReport.CreateDate = Convert.ToDateTime(dateEdit1.Text);
            }
            psp_ForecastReport.Remark = memoEdit1.Text;

            if (_isEdit)
            {
                try
                {
                    Common.Services.BaseService.Update<PowerEachList>(psp_ForecastReport);
                }
                catch
                {
                    MsgBox.Show("�޸ļƻ�������");
                    return;
                }
            }
            else
            {
                try
                { PSP_PlanTable_HuaiBei plan =new PSP_PlanTable_HuaiBei ();
              PowerEachList obj=(PowerEachList)Common.Services.BaseService.GetObject("SelectPowerEachListListByTypesAndListName", psp_ForecastReport);
              if (obj != null)
              {
                  MsgBox.Show("�Ѿ����ڴ���Ŀ�����ƣ�");
                  return;
              }

              Common.Services.BaseService.Create<PowerEachList>(psp_ForecastReport);
              PowerEachList oo = (PowerEachList)Common.Services.BaseService.GetObject("SelectPowerEachListListByTypesAndListName", psp_ForecastReport);
              DateTime dtt = new DateTime();
              dtt = DateTime.Now;
                      plan.UID=Guid.NewGuid().ToString();
                    plan.Title="ʱ����";
                    plan.Flag2 = oo.UID;
                    plan.ParentID="0";
                    plan.KeyFlag="time1";
                    plan.ItemSB = "0";
                    plan.ItemPF = "0";
                    plan.KYWC = "0";
                    plan.KYPS = "0";
                    plan.PSYJ = "0";
                   // plan.CSSC = "0";
                   // plan.JSGFSSB = "0";
                   // plan.ZBSB = "0";
                   // plan.ZBSHDateTime = "0";
                    ////plan.CSSC = DateTime.Now;
                    ////plan.JSGFSSB = DateTime.Now;
                    ////plan.ZBSB = DateTime.Now;
                    ////plan.ZBSHDateTime = DateTime.Now;
                    plan.XZYJS = "0";
                    plan.HPPF = "0";
                    plan.TDYS = "0";
                    plan.SBHZSQ = "0";
                    plan.XMHZ = "0";
                    plan.JHKSDateTime = "0";
                    plan.JHTCDateTime = "0";
                    //plan.JHTCDateTime_GuiHua = DateTime.Now;
                    plan.CreateDate = dtt.AddSeconds(1);
                    Common.Services.BaseService.Create<PSP_PlanTable_HuaiBei>(plan);
                      plan.UID=Guid.NewGuid().ToString();
                    plan.Title="220ǧ�����繤��";
                    plan.Flag2 = oo.UID;
                    plan.ParentID="0";
                    plan.KeyFlag="220";
                    plan.ItemSB = "";
                    plan.ItemPF = "";
                    plan.KYWC = "";
                    plan.KYPS = "";
                    plan.PSYJ = "";
                    //plan.CSSC = DateTime.Now;
                    //plan.JSGFSSB = DateTime.Now;
                    //plan.ZBSB = DateTime.Now;
                    //plan.ZBSHDateTime = DateTime.Now;
                    plan.XZYJS = "";
                    plan.HPPF = "";
                    plan.TDYS = "";
                    plan.SBHZSQ = "";
                    plan.XMHZ = "";
                    plan.JHKSDateTime = "";
                    plan.JHTCDateTime = "";
                    plan.JHTCDateTime_GuiHua = DateTime.Now;
                    plan.CreateDate = dtt.AddSeconds(2);
                    Common.Services.BaseService.Create<PSP_PlanTable_HuaiBei>(plan);

                        plan.UID=Guid.NewGuid().ToString();
                    plan.Title="ʱ����";
                    plan.Flag2 = oo.UID;
                    plan.ParentID="0";
                    plan.KeyFlag="time2";
                    plan.ItemSB = "0";
                    plan.ItemPF = "0";
                    plan.KYWC = "0";
                    plan.KYPS = "0";
                    plan.PSYJ = "0";
                    //plan.CSSC = DateTime.Now;
                    //plan.JSGFSSB = DateTime.Now;
                    //plan.ZBSB = DateTime.Now;
                    //plan.ZBSHDateTime = DateTime.Now;
                    plan.XZYJS = "0";
                    plan.HPPF = "0";
                    plan.TDYS = "0";
                    plan.SBHZSQ = "0";
                    plan.XMHZ = "0";
                    plan.JHKSDateTime = "0";
                    plan.JHTCDateTime = "0";
                    plan.JHTCDateTime_GuiHua =null;
                    plan.CreateDate = dtt.AddSeconds(3);
                    Common.Services.BaseService.Create<PSP_PlanTable_HuaiBei>(plan);
                       plan.UID=Guid.NewGuid().ToString();
                    plan.Title="110ǧ�����繤��";
                    plan.Flag2 = oo.UID;
                    plan.ParentID="0";
                    plan.KeyFlag="110";
                    plan.ItemSB = "";
                    plan.ItemPF = "";
                    plan.KYWC = "";
                    plan.KYPS = "";
                    plan.PSYJ = "";
                    //plan.CSSC = DateTime.Now;
                    //plan.JSGFSSB = DateTime.Now;
                    //plan.ZBSB = DateTime.Now;
                    //plan.ZBSHDateTime = DateTime.Now;
                    plan.XZYJS = "";
                    plan.HPPF = "";
                    plan.TDYS = "";
                    plan.SBHZSQ = "";
                    plan.XMHZ = "";
                    plan.JHKSDateTime = "";
                    plan.JHTCDateTime = "";
                    plan.JHTCDateTime_GuiHua = DateTime.Now;
                    plan.CreateDate = dtt.AddSeconds(4);
                    Common.Services.BaseService.Create<PSP_PlanTable_HuaiBei>(plan);
                      plan.UID=Guid.NewGuid().ToString();
                    plan.Title="ʱ����";
                    plan.Flag2 = oo.UID;
                    plan.ParentID="0";
                    plan.KeyFlag="time3";
                    plan.ItemSB = "0";
                    plan.ItemPF = "0";
                    plan.KYWC = "0";
                    plan.KYPS = "0";
                    plan.PSYJ = "0";
                    //plan.CSSC = DateTime.Now;
                    //plan.JSGFSSB = DateTime.Now;
                    //plan.ZBSB = DateTime.Now;
                    //plan.ZBSHDateTime = DateTime.Now;
                    plan.XZYJS = "0";
                    plan.HPPF = "0";
                    plan.TDYS = "0";
                    plan.SBHZSQ = "0";
                    plan.XMHZ = "0";
                    plan.JHKSDateTime = "0";
                    plan.JHTCDateTime = "0";
                    plan.JHTCDateTime_GuiHua = null;
                    plan.CreateDate = dtt.AddSeconds(5);
                    Common.Services.BaseService.Create<PSP_PlanTable_HuaiBei>(plan);
                        plan.UID=Guid.NewGuid().ToString();
                    plan.Title="��������";
                    plan.Flag2 = oo.UID;
                    plan.ParentID="0";
                    plan.KeyFlag="kuojian";
                    plan.ItemSB = "";
                    plan.ItemPF = "";
                    plan.KYWC = "";
                    plan.KYPS = "";
                    plan.PSYJ = "";
                    //plan.CSSC = DateTime.Now;
                    //plan.JSGFSSB = DateTime.Now;
                    //plan.ZBSB = DateTime.Now;
                    //plan.ZBSHDateTime = DateTime.Now;
                    plan.XZYJS = "";
                    plan.HPPF = "";
                    plan.TDYS = "";
                    plan.SBHZSQ = "";
                    plan.XMHZ = "";
                    plan.JHKSDateTime = "";
                    plan.JHTCDateTime = "";
                    plan.JHTCDateTime_GuiHua = DateTime.Now;
                    plan.CreateDate = dtt.AddSeconds(6);
                    Common.Services.BaseService.Create<PSP_PlanTable_HuaiBei>(plan);
                        plan.UID = Guid.NewGuid().ToString();
                    plan.Title = "220ǧ������";
                    plan.Flag2 = oo.UID;
                    plan.ParentID = "0";
                    plan.KeyFlag = "220ǧ��";
                    plan.ItemSB = "";
                    plan.ItemPF = "";
                    plan.KYWC = "";
                    plan.KYPS = "";
                    plan.PSYJ = "";
                    //plan.CSSC = DateTime.Now;
                    //plan.JSGFSSB = DateTime.Now;
                    //plan.ZBSB = DateTime.Now;
                    //plan.ZBSHDateTime = DateTime.Now;
                    plan.XZYJS = "";
                    plan.HPPF = "";
                    plan.TDYS = "";
                    plan.SBHZSQ = "";
                    plan.XMHZ = "";
                    plan.JHKSDateTime = "";
                    plan.JHTCDateTime = "";
                    plan.JHTCDateTime_GuiHua = null;
                    plan.CreateDate = dtt.AddSeconds(7);
                    Common.Services.BaseService.Create<PSP_PlanTable_HuaiBei>(plan);
                       plan.UID = Guid.NewGuid().ToString();
                       plan.Title = "110ǧ������";
                    plan.Flag2 = oo.UID;
                    plan.ParentID = "0";
                    plan.KeyFlag = "110ǧ��";
                    plan.ItemSB = "";
                    plan.ItemPF = "";
                    plan.KYWC = "";
                    plan.KYPS = "";
                    plan.PSYJ = "";
                    //plan.CSSC = DateTime.Now;
                    //plan.JSGFSSB = DateTime.Now;
                    //plan.ZBSB = DateTime.Now;
                    //plan.ZBSHDateTime = DateTime.Now;
                    plan.XZYJS = "";
                    plan.HPPF = "";
                    plan.TDYS = "";
                    plan.SBHZSQ = "";
                    plan.XMHZ = "";
                    plan.JHKSDateTime = "";
                    plan.JHTCDateTime = "";
                    plan.JHTCDateTime_GuiHua = null;
                    plan.CreateDate = dtt.AddSeconds(8);
                    Common.Services.BaseService.Create<PSP_PlanTable_HuaiBei>(plan);

                }
                catch
                {
                    MsgBox.Show("�½��ƻ�������");
                    return;
                }
            }

            DialogResult = DialogResult.OK;
        }