Example #1
0
        public void InitSodata()
        {
            if (ctrlPowerEachList1.FocusedObject == null)
                return;

            string sid = typeFlag2= ctrlPowerEachList1.FocusedObject.UID;

            Hashtable hs = new Hashtable();
            Hashtable hs1 = new Hashtable();
            ddd = DateTime.Now;
            sss += "2:" + ddd.ToString();
            IList<Itop.Domain.Graphics.LineInfo> listLineInfo = Services.BaseService.GetList<Itop.Domain.Graphics.LineInfo>("SelectLineInfoByPowerID", sid);
            foreach (Itop.Domain.Graphics.LineInfo l1 in listLineInfo)
            {
                hs.Add(Guid.NewGuid().ToString(), l1.UID);
            }
            ddd = DateTime.Now;
            sss += "3:" + ddd.ToString();
            IList<substation> listsubstation = Services.BaseService.GetList<substation>("SelectsubstationByPowerID2", sid);
            foreach (substation s1 in listsubstation)
            {
                hs.Add(Guid.NewGuid().ToString(), s1.UID);
            }
            ddd = DateTime.Now;
            sss += "4:" + ddd.ToString();
            PSP_PowerProValues_LangFang psp_Type = new PSP_PowerProValues_LangFang();
            psp_Type.Flag2 = sid;
            IList<PSP_PowerProValues_LangFang> listProTypes = Common.Services.BaseService.GetList<PSP_PowerProValues_LangFang>("SelectPSP_PowerProValues_LangFangByFlag2", psp_Type);
            foreach (PSP_PowerProValues_LangFang ps in listProTypes)
            {
                hs1.Add(Guid.NewGuid().ToString(), ps.Code);
            }
            ddd = DateTime.Now;
            sss += "5:" + ddd.ToString();
            foreach (PSP_PowerProValues_LangFang p1 in listProTypes)
            {

                if (p1.Code != "" && !hs.ContainsValue(p1.Code) && p1.ParentID != "0")
                {
                    //删除
                    Services.BaseService.Delete<PSP_PowerProValues_LangFang>(p1);
                }
            }
            ddd = DateTime.Now;
            sss += "6:" + ddd.ToString();

            foreach (Itop.Domain.Graphics.LineInfo l2 in listLineInfo)
            {
                if (!hs1.ContainsValue(l2.UID) && l2.Voltage != "")
                {
                    //添加
                    try
                    {
                        PSP_PowerProValues_LangFang ps2 = new PSP_PowerProValues_LangFang();
                        ps2.ParentID = l2.Voltage.ToUpper().Replace("KV", "");
                        ps2.L3 = l2.LineName;
                        ps2.Code = l2.UID;
                        ps2.Flag = 1;
                        ps2.Flag2 = sid;
                        ps2.L4 = l2.Voltage;
                        ps2.L8 = double.Parse(l2.Length).ToString(); ;
                        ps2.L9 = l2.LineType;
                        ps2.ID = Guid.NewGuid().ToString();
                        Services.BaseService.Create<PSP_PowerProValues_LangFang>(ps2);
                    }
                    catch( Exception ex){
                        System.Console.WriteLine(ex.Message);
                    }

                }

                if (hs1.ContainsValue(l2.UID) && l2.Voltage != "")
                {
                    //更新
                    try
                    {
                        PSP_PowerProValues_LangFang p2 =   new PSP_PowerProValues_LangFang();
                        p2.Code = l2.UID;
                        p2.Flag2 = sid;
                        PSP_PowerProValues_LangFang ps2=(PSP_PowerProValues_LangFang)Services.BaseService.GetObject("SelectPSP_PowerProValues_LangFangByselectObject", p2);
                        ps2.ParentID = l2.Voltage.ToUpper().Replace("KV", "");
                        ps2.L3 = l2.LineName;
                        ps2.Flag = 1;
                        ps2.L4 = l2.Voltage;
                        ps2.L8 = double.Parse(l2.Length).ToString(); ;
                        ps2.L9 = l2.LineType;

                        Services.BaseService.Update("UpdatePSP_PowerProValues_LangFangByCode", ps2);
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine(ex.Message);
                    }

                }
            }
            ddd = DateTime.Now;
            sss += "7:" + ddd.ToString();

            //ps.Type = OBJ.L7;
            Project_Sum psp = new Project_Sum();
            psp.S5 = "2";
            IList<Project_Sum> sum = Common.Services.BaseService.GetList<Project_Sum>("SelectProject_SumByS5", psp);

            Hashtable ha = new Hashtable();
            ArrayList al=new ArrayList();
            foreach (substation s2 in listsubstation)
            {

                if (!hs1.ContainsValue(s2.UID) && s2.ObligateField1 != "")
                {

                    ha.Clear();
                    al.Clear();
                    int kk = 0;
                    //添加
                    try
                    {
                        Substation_Info sub = new Substation_Info();
                        sub.Code = s2.UID;
                        Substation_Info station = (Substation_Info)Common.Services.BaseService.GetObject("SelectSubstation_InfoByCode", sub);

                        PSP_PowerProValues_LangFang ps3 = new PSP_PowerProValues_LangFang();
                        ps3.ParentID = s2.ObligateField1;
                        ps3.L3 = s2.EleName;
                        ps3.Code = s2.UID;
                        ps3.Flag = 2;
                        ps3.Flag2 = sid;
                        ps3.L4 = s2.ObligateField1.ToString();
                        if (station != null)
                        {
                            ps3.L5 = station.L3.ToString();
                        }
                        foreach (Project_Sum ps1 in sum)
                        {
                            if (s2.ObligateField1.ToString() == ps1.S1.ToString())
                            {
                                try
                                {
                                    double mva = double.Parse(s2.Number.ToString());
                                    double t5 = Convert.ToDouble(ps1.T5);//单台容量
                                    int ta = Convert.ToInt32(ps1.T1);//主变台数
                                    if (mva == (t5 * ta))
                                    {
                                        ha.Add(t5, ta);
                                        al.Add(t5);

                                    }
                                }
                                catch { }
                            }
                        }
                        if (al.Count > 0)
                        {
                            double va = Convert.ToDouble(al[0].ToString());
                            for (int ii = 0; ii < al.Count; ii++)
                            {
                                if (va < Convert.ToDouble(al[ii].ToString()))
                                    va = Convert.ToDouble(al[ii].ToString());
                            }
                            ps3.L5 = ha[va].ToString();
                            ps3.L6 = va.ToString();
                        }
                        else
                        {
                            ps3.L5 = "";
                            ps3.L6 = "";
                        }
                        ps3.IsConn = double.Parse(s2.Number.ToString()).ToString();//总容量
                        ps3.ID = Guid.NewGuid().ToString();
                        Services.BaseService.Create<PSP_PowerProValues_LangFang>(ps3);
                    }
                    catch { }

                }
                if (hs1.ContainsValue(s2.UID) && s2.ObligateField1 != "")
                {
                    ha.Clear();
                    al.Clear();
                    int kk = 0;
                    //更新
                    try
                    {
                        Substation_Info sub = new Substation_Info();
                        sub.Code = s2.UID;
                        Substation_Info station = (Substation_Info)Common.Services.BaseService.GetObject("SelectSubstation_InfoByCode", sub);

                        PSP_PowerProValues_LangFang p3 = new PSP_PowerProValues_LangFang();
                        p3.Code = s2.UID;
                        p3.Flag2 = sid;
                        PSP_PowerProValues_LangFang ps3 = (PSP_PowerProValues_LangFang)Services.BaseService.GetObject("SelectPSP_PowerProValues_LangFangByselectObject", p3);
                        ps3.ParentID = s2.ObligateField1;
                        ps3.L3 = s2.EleName;
                        ps3.Flag = 2;
                        ps3.L4 = s2.ObligateField1.ToString();
                        if (station != null)
                        {
                            ps3.L5 = station.L3.ToString();
                        }
                        foreach (Project_Sum ps1 in sum)
                        {
                            if (s2.ObligateField1.ToString() == ps1.S1.ToString())
                            {
                                try
                                {
                                    double mva = double.Parse(s2.Number.ToString());
                                    double t5 = Convert.ToDouble(ps1.T5);//单台容量
                                    int ta = Convert.ToInt32(ps1.T1);//主变台数
                                    if (mva == (t5 * ta))
                                    {
                                        ha.Add(t5, ta);
                                        al.Add(t5);

                                    }
                                }
                                catch { }
                            }
                        }
                        if (al.Count > 0)
                        {
                            double va = Convert.ToDouble(al[0].ToString());
                            for (int ii = 0; ii < al.Count; ii++)
                            {
                                if (va < Convert.ToDouble(al[ii].ToString()))
                                    va = Convert.ToDouble(al[ii].ToString());
                            }
                            ps3.L5 = ha[va].ToString();
                            ps3.L6 = va.ToString();
                        }
                        else
                        {
                            ps3.L5 = "";
                            ps3.L6 = "";
                        }
                        ps3.IsConn = double.Parse(s2.Number.ToString()).ToString();//总容量
                        Services.BaseService.Update("UpdatePSP_PowerProValues_LangFangByCode", ps3);
                    }
                    catch { }
                }
            }
            ddd = DateTime.Now;
            sss += "8:" + ddd.ToString();
            if (updat == "true")
            {
                LoadDatadata();
            }
            else if (updat == "false")
            {

                UpdataLoadDatadata();
                updat = "true";
            }
            else
            {
                LoadData();
                updat = "true";
            }
            ddd = DateTime.Now;
            sss += "9:" + ddd.ToString();
        }
Example #2
0
        /// <summary>
        /// ɾ���������
        /// </summary>
        public void DeleteObject(string lb)
        {
            //��ȡ�������
            PowerEachList obj = FocusedObject;
            if (obj == null)
            {
                bl = false;
                return;
            }

            int coun = 0;

            switch (lb)
            {
                case "xuqiu":
                PowerTypes pt = new PowerTypes();
                pt.Flag2 = obj.UID;
                IList<PowerTypes> li = Services.BaseService.GetList<PowerTypes>("SelectPowerTypesByFlag2", pt);
                coun = li.Count;

                    break;
                case "xihua":
                    PowerProjectTypes pt1 = new PowerProjectTypes();
                    pt1.Flag2 = obj.UID;
                    IList<PowerProjectTypes> li1 = Services.BaseService.GetList<PowerProjectTypes>("SelectPowerProjectTypesByFlag2", pt1);
                    coun = li1.Count;
                    break;
                case "shebei":
                    PowerStuffTypes pt2 = new PowerStuffTypes();
                    pt2.Flag2 = obj.UID;
                    IList<PowerStuffTypes> li2 = Services.BaseService.GetList<PowerStuffTypes>("SelectPowerStuffTypesByFlag2", pt2);
                    coun = li2.Count;
                    break;
                case "fanwei":
                    PowersTypes pt3 = new PowersTypes();
                    pt3.Flag2 = obj.UID;
                    IList<PowersTypes> li3 = Services.BaseService.GetList<PowersTypes>("SelectPowersTypesByFlag2", pt3);
                    coun = li3.Count;
                    break;
                case "sb":
                    PowerProTypes pt4 = new PowerProTypes();
                    pt4.Flag2 = obj.UID;
                    IList<PowerProTypes> li4 = Services.BaseService.GetList<PowerProTypes>("SelectPowerProTypesByFlag2INParent", pt4);
                    coun = li4.Count;
                    break;
                case "gusuan":
                    PSP_PowerProValues_LangFang pt5 = new PSP_PowerProValues_LangFang();
                    pt5.Flag2 = obj.UID;
                    IList<PSP_PowerProValues_LangFang> li5 = Services.BaseService.GetList<PSP_PowerProValues_LangFang>("SelectPSP_PowerProValues_LangFangByFlag2INParent", pt5);
                    coun = li5.Count;
                    break;
            }

            if (coun > 0)
            {
                MsgBox.Show("�÷��������м�¼���޷�ɾ��");
                bl = false;
                return;
            }

            //����ȷ��
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                bl = false;
                return;
            }

            //ִ��ɾ������
            try
            {
                Services.BaseService.Delete<PowerEachList>(obj);

                if (lb == "sb")
                {
                    Services.BaseService.Update("DeletePowerPicSelect1", obj.UID);
                    Services.BaseService.Update("DeletePowerProTypesInFlag2", obj.UID);
                }
                if (lb == "gusuan")
                {
                    Services.BaseService.Update("DeletePowerPicSelect1", obj.UID);
                    Services.BaseService.Update("DeletePowerProTypesInFlag2", obj.UID);
                }
            }
            catch
            {
                //Debug.Fail(exc.Message);
                //HandleException.TryCatch(exc);
                return;
            }

            this.gridView.BeginUpdate();
            //��ס��ǰ����������
            int iOldHandle = this.gridView.FocusedRowHandle;
            //��������ɾ��
            ObjectList.Remove(obj);
            //ˢ�±��
            gridControl.RefreshDataSource();
            //�����µĽ���������
            GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle);
            this.gridView.EndUpdate();
        }
Example #3
0
        private void barButtonItem12_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TreeListNode focusedNode = treeList1.FocusedNode;

            if (focusedNode == null)
            {
                return;
            }

            FormAddInfo_LangFang frm = new FormAddInfo_LangFang();
            frm.Text = "增加" + focusedNode.GetValue("L3") + "的子项目";
            frm.FlagId = typeFlag2;
            frm.ParentID = focusedNode.GetValue("ID").ToString();
            frm.Isupdate = false;
            if (frm.ShowDialog() == DialogResult.OK)
            {

                obj = frm.OBJ;
                TreeListColumn column = treeList1.Columns["L10"];
                CalculateSum(focusedNode, column, obj.L10, false);
              ////      LoadData();
              ////      FoucsLocation(psp_Type.ID, treeList1.Nodes);
                    //treeList1.RefreshDataSource();
                    //dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow()));
                WaitDialogForm wait = null;

                try
                {
                    wait = new WaitDialogForm("", "正在计算数据, 请稍候...");
                    LoadDatadata();
                    wait.Close();
                   // MsgBox.Show("计算成功");

                }
                catch
                {
                    wait.Close();
                }

               //treeList1.FocusedNode.SetValue(treeList1.FocusedColumn.FieldName, lastEditValue);
            }
        }
Example #4
0
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            if (treeList1.FocusedNode.HasChildren)
            {
                MsgBox.Show("此项目下有子项目,请先删除子项目!");
                return;
            }
            if (treeList1.FocusedNode.ParentNode == null)
            {
                if (MsgBox.ShowYesNo("是否删除项目 " + treeList1.FocusedNode.GetValue("L3") + "?") == DialogResult.Yes)
                {
                    PowerProValues PowerValues = new PowerProValues();
                    PowerValues.TypeID = treeList1.FocusedNode["ID"].ToString();
                    PowerValues.Year = typeFlag2;

                    PSP_PowerProValues_LangFang ppss = new PSP_PowerProValues_LangFang();
                    ppss.ID = treeList1.FocusedNode["ID"].ToString();
                    ppss.Flag2 = typeFlag2;

                    PSP_PowerProValues_LangFang ppss1 = Services.BaseService.GetOneByKey<PSP_PowerProValues_LangFang>(ppss);
                    PowerValues.TypeID1 = ppss1.Code;

                    try
                    {
                        //DeletePowerValuesByType里面删除数据和分类

                        Common.Services.BaseService.Update("DeletePowerProValuesByType", PowerValues);

                        TreeListNode brotherNode = null;
                        try
                        {
                            if (treeList1.FocusedNode.ParentNode.Nodes.Count > 1)
                            {
                                brotherNode = treeList1.FocusedNode.PrevNode;
                                if (brotherNode == null)
                                {
                                    brotherNode = treeList1.FocusedNode.NextNode;
                                }
                            }
                        }
                        catch { }
                        Common.Services.BaseService.Update("DeletePSP_PowerProValues_LangFangByIDFlag2", ppss);
                        treeList1.DeleteNode(treeList1.FocusedNode);
                        WaitDialogForm wait = null;

                        try
                        {
                            wait = new WaitDialogForm("", "正在计算数据, 请稍候...");
                            LoadDatadata();
                            wait.Close();
                        //    MsgBox.Show("计算成功");

                        }
                        catch
                        {
                            wait.Close();
                        }

                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("删除出错:" + ex.Message);
                    }
                }
                return;
            }
            else {

            if (MsgBox.ShowYesNo("是否删除项目 " + treeList1.FocusedNode.GetValue("L3") + "?") == DialogResult.Yes)
            {
                bool flag = false;
                PowerProValues PowerValues = new PowerProValues();
                PowerValues.TypeID = treeList1.FocusedNode["ID"].ToString();
                PowerValues.Year = typeFlag2;

                PSP_PowerProValues_LangFang ppss = new PSP_PowerProValues_LangFang();
                ppss.ID=treeList1.FocusedNode["ID"].ToString();
                ppss.Flag2=typeFlag2;

                PSP_PowerProValues_LangFang ppss1 = Services.BaseService.GetOneByKey<PSP_PowerProValues_LangFang>(ppss);
                PowerValues.TypeID1 = ppss1.Code;

                try
                {
                    //DeletePowerValuesByType里面删除数据和分类

                    Common.Services.BaseService.Update("DeletePowerProValuesByType", PowerValues);

                    TreeListNode brotherNode = null;
                    try
                    {
                        if (treeList1.FocusedNode.ParentNode.Nodes.Count > 1)
                        {
                            flag = false;
                            brotherNode = treeList1.FocusedNode.PrevNode;
                            if (brotherNode == null)
                            {
                                brotherNode = treeList1.FocusedNode.NextNode;
                            }
                        }
                        if (treeList1.FocusedNode.ParentNode.Nodes.Count == 1)
                        {
                            flag = true;
                        }
                     }
                    catch { }
                    Common.Services.BaseService.Update("DeletePSP_PowerProValues_LangFangByIDFlag2",ppss);
                    TreeListColumn column = treeList1.Columns["L10"];
                    treeList1.DeleteNode(treeList1.FocusedNode);
                    if(flag==false)
                       CalculateSum(treeList1.FocusedNode.ParentNode, column, 0,false);
                    else
                       CalculateSum(treeList1.FocusedNode, column, 0,false);
                   WaitDialogForm wait = null;

                   try
                   {
                       wait = new WaitDialogForm("", "正在计算数据, 请稍候...");
                       LoadDatadata();
                       wait.Close();
                       //MsgBox.Show("计算成功");

                   }
                   catch
                   {
                       wait.Close();
                   }

                }
                catch (Exception ex)
                {
                    MsgBox.Show("删除出错:" + ex.Message);
                }
            }
            }
              //            InitSodata();
              //obj= frm.OBJ;

              // CalculateSum(focusedNode, column, double.Parse(obj.L10));
        }
Example #5
0
        private bool SaveRemarkValue(string typeID, string value)
        {
            PSP_PowerProValues_LangFang ppt = new PSP_PowerProValues_LangFang();
            ppt.ID = typeID;
            ppt.Flag2=typeFlag2;

            PSP_PowerProValues_LangFang ps = Services.BaseService.GetOneByKey<PSP_PowerProValues_LangFang>(ppt);//<PowerProTypes>(typeID);

            ps.Remark = value;
            try
            {
                Common.Services.BaseService.Update<PSP_PowerProValues_LangFang>(ps);
            }
            catch (Exception ex)
            {
                MsgBox.Show("保存数据出错:" + ex.Message);
                return false;
            }
            return true;
        }
Example #6
0
        //重新计算造价
        private void UpdataLoadDatadata()
        {
            try
            {
                if (dataTable != null)
                {
                    dataTable.Columns.Clear();
                    treeList1.Nodes.Clear();
                }
                ddd = DateTime.Now;
                sss += " 10:" + ddd.ToString();
                PSP_PowerProValues_LangFang psp_Type = new PSP_PowerProValues_LangFang();
                psp_Type.Flag2 = typeFlag2;
                IList listTypes = new ArrayList();
                try
                {
                    listTypes = Common.Services.BaseService.GetList("SelectPSP_PowerProValues_LangFangByFlag2", psp_Type);

                }
                catch (Exception ex)
                { MsgBox.Show(ex.Message); }
                ddd = DateTime.Now;
                sss += " 11:" + ddd.ToString();
                Project_Sum ps = new Project_Sum();
                ps.S5 = "1";
                IList<Project_Sum> sumline = Common.Services.BaseService.GetList<Project_Sum>("SelectProject_SumByS5", ps);
                ps.S5 = "2";
                IList<Project_Sum> sumsubsation = Common.Services.BaseService.GetList<Project_Sum>("SelectProject_SumByS5", ps);
                Hashtable ha = new Hashtable();
                ArrayList al = new ArrayList();

                foreach (PSP_PowerProValues_LangFang psplf in listTypes)
                {
                    if (psplf.Flag == 1)//纯线路造价计算
                    {
                        if (psplf.L8 == "" || psplf.L8 == null)
                        {
                            psplf.L8 = "0";

                        }
                        foreach (Project_Sum psum in sumline)
                        {
                            if (psum.L1 == psplf.L9 && psum.S1 == psplf.L4)
                            {
                                if (psum.Num.ToString() == null || psum.Num.ToString() == "")
                                    psum.Num = 0;

                                psplf.L10 =Math.Round(psum.Num * double.Parse(psplf.L8),2);

                                if (psplf.L11 == "" || psplf.L11 == null)
                                {
                                    psplf.L11 = "0";
                                }
                                psplf.L12 = Math.Round(psplf.L10 + double.Parse(psplf.L11), 2);
                                break;
                            }

                        }
                    }
                    if (psplf.Flag == 2)
                    {
                        ha.Clear();
                        al.Clear();
                        double sumvaluedata = 0;
                        double sumvalueLine = 0;
                        if (psplf.L6 != "" && psplf.L6 != null && psplf.L5 != "" && psplf.L5 != null)//变电站内的电站造价计算
                        {
                            foreach (Project_Sum psum in sumsubsation)
                            {
                                if (psum.S1 == psplf.L4)
                                {
                                    try
                                    {
                                        double mva = double.Parse(psplf.IsConn.ToString());
                                        double t5 = Convert.ToDouble(psum.T5);//单台容量
                                        int ta = Convert.ToInt32(psum.T1);//主变台数
                                        if (mva == (t5 * ta))
                                        {
                                            ha.Add(t5, ta);
                                            al.Add(t5);

                                        }
                                    }
                                    catch { }
                                    if (al.Count >0)
                                    {
                                        double va = Convert.ToDouble(al[0].ToString());
                                        for (int ii = 0; ii < al.Count; ii++)
                                        {
                                            if (va < Convert.ToDouble(al[ii].ToString()))
                                                va = Convert.ToDouble(al[ii].ToString());
                                        }
                                        psplf.L5 = ha[va].ToString();
                                        psplf.L6 = va.ToString();
                                    }

                                    else
                                    {
                                        psplf.L5 = "";
                                        psplf.L6 = "";

                                    }
                                }
                            }
                             foreach (Project_Sum psum in sumsubsation)
                             {
                                 if (psum.T1 == psplf.L5 && psum.T5 == psplf.L6 && psum.S1 == psplf.L4)
                                 {
                                     if (psum.Num.ToString() == null || psum.Num.ToString() == "")
                                         psum.Num = 0;

                                     sumvaluedata = psum.Num;
                                     break;
                                 }
                            }
                        }
                        if (psplf.L8 != "" && psplf.L8 != null)//变电站内的线路造价计算
                        {
                            foreach (Project_Sum psum in sumline)
                            {
                                if (psum.L1 == psplf.L9 && psum.S1 == psplf.L4)
                                {
                                    if (psum.Num.ToString() == null || psum.Num.ToString() == "")
                                        psum.Num = 0;

                                    sumvalueLine = psum.Num * double.Parse(psplf.L8);
                                    break;
                                }
                            }
                        }
                         psplf.L10 =Math.Round(sumvaluedata + sumvalueLine,2);

                        if (psplf.L11== "" || psplf.L11 == null)
                        {
                            psplf.L11 = "0";
                        }
                        psplf.L12 =Math.Round(psplf.L10 + double.Parse(psplf.L11),2);
                        Services.BaseService.Update("UpdatePSP_PowerProValues_LangFangByid",psplf);
                    }
                }

                ddd = DateTime.Now;
                sss += " 12:" + ddd.ToString();//测试运算时间,可删除

                sss += " 13:" + ddd.ToString();//测试运算时间,可删除
                dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(PSP_PowerProValues_LangFang));

                treeList1.DataSource = dataTable;

                treeList1.Columns["L3"].Caption = "工程名称";
                treeList1.Columns["L3"].Width = 80;
                treeList1.Columns["L3"].OptionsColumn.AllowEdit = false;
                treeList1.Columns["L3"].OptionsColumn.AllowSort = false;
                treeList1.Columns["Title"].VisibleIndex = -1;
                treeList1.Columns["Title"].OptionsColumn.ShowInCustomizationForm = false;
                treeList1.Columns["Flag"].VisibleIndex = -1;
                treeList1.Columns["Flag"].SortOrder = System.Windows.Forms.SortOrder.None;
                treeList1.Columns["Flag"].OptionsColumn.ShowInCustomizationForm = false;
                treeList1.Columns["Flag2"].VisibleIndex = -1;
                treeList1.Columns["Flag2"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["CreateTime"].VisibleIndex = -1;
                treeList1.Columns["CreateTime"].OptionsColumn.ShowInCustomizationForm = false;
                treeList1.Columns["CreateTime"].SortOrder = System.Windows.Forms.SortOrder.None;

                treeList1.Columns["UpdateTime"].VisibleIndex = -1;
                treeList1.Columns["UpdateTime"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["UpdateTime"].VisibleIndex = -1;
                treeList1.Columns["UpdateTime"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["Code"].VisibleIndex = -1;
                treeList1.Columns["Code"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L1"].VisibleIndex = -1;
                treeList1.Columns["L1"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L2"].VisibleIndex = -1;
                treeList1.Columns["L2"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L11"].VisibleIndex = -1;
                treeList1.Columns["L11"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L12"].VisibleIndex = -1;
                treeList1.Columns["L12"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L13"].VisibleIndex = -1;
                treeList1.Columns["L13"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L14"].VisibleIndex = -1;
                treeList1.Columns["L14"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L15"].VisibleIndex = -1;
                treeList1.Columns["L15"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L16"].VisibleIndex = -1;
                treeList1.Columns["L16"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L17"].VisibleIndex = -1;
                treeList1.Columns["L17"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L18"].VisibleIndex = -1;
                treeList1.Columns["L18"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L19"].VisibleIndex = -1;
                treeList1.Columns["L19"].OptionsColumn.ShowInCustomizationForm = false;
                treeList1.Columns["Remark"].VisibleIndex = -1;
                treeList1.Columns["Remark"].OptionsColumn.ShowInCustomizationForm = false;
                AddColumn2();
                PowerProYears psp_Year = new PowerProYears();
                psp_Year.Flag = typeFlag2;

                Application.DoEvents();

                LoadValues();
                TreeListColumn column = treeList1.Columns["L10"];
                TreeListColumn column1 = treeList1.Columns["L12"];
                for (int i = 0; i < treeList1.Nodes.Count; i++)
                {

                    CalculateNodesValue(treeList1.Nodes[i], column, column1);
                }
                treeList1.ExpandAll();
            }
            catch
            {

            }
        }
Example #7
0
        private void LoadDatadata()
        {
            try
            {
                if (dataTable != null)
                {
                    dataTable.Columns.Clear();
                    treeList1.Nodes.Clear();
                }
                ddd = DateTime.Now;
                sss += " 10:" + ddd.ToString();
                PSP_PowerProValues_LangFang psp_Type = new PSP_PowerProValues_LangFang();
                psp_Type.Flag2 = typeFlag2;
                IList listTypes = new ArrayList();
                try
                {
                    listTypes = Common.Services.BaseService.GetList("SelectPSP_PowerProValues_LangFangByFlag2", psp_Type);

                }
                catch (Exception ex)
                { MsgBox.Show(ex.Message); }
                ddd = DateTime.Now;
                sss += " 11:" + ddd.ToString();
                Project_Sum ps = new Project_Sum();
                ps.S5 = "1";
                IList<Project_Sum> sumline = Common.Services.BaseService.GetList<Project_Sum>("SelectProject_SumByS5", ps);
                ps.S5 = "2";
                IList<Project_Sum> sumsubsation = Common.Services.BaseService.GetList<Project_Sum>("SelectProject_SumByS5", ps);

                foreach (PSP_PowerProValues_LangFang psplf in listTypes)
                {
                    if (psplf.Flag == 1)//纯线路造价计算
                    {
                        if (psplf.L8 == "" || psplf.L8 == null)
                        {
                            psplf.L8 = "0";

                        }
                        foreach (Project_Sum psum in sumline)
                        {
                            if (psum.L1 == psplf.L9 && psum.S1 == psplf.L4)
                            {
                                if (psum.Num.ToString() == null || psum.Num.ToString() == "")
                                    psum.Num = 0;

                                psplf.L10 = Math.Round(psum.Num * double.Parse(psplf.L8), 2);

                                if (psplf.L11 == "" || psplf.L11 == null)
                                {
                                    psplf.L11 = "0";
                                }
                                psplf.L12 = Math.Round(psplf.L10 + double.Parse(psplf.L11), 2);
                                break;
                            }

                        }
                    }
                    if (psplf.Flag == 2)
                    {
                        double sumvaluedata = 0;
                        double sumvalueLine = 0;
                        if (psplf.L6 != "" && psplf.L6 != null && psplf.L5 != "" && psplf.L5 != null)//变电站内的电站造价计算
                        {
                            foreach (Project_Sum psum in sumsubsation)
                            {
                                if (psum.T1 == psplf.L5 && psum.T5 == psplf.L6 && psum.S1 == psplf.L4)
                                {
                                    if (psum.Num.ToString() == null || psum.Num.ToString() == "")
                                        psum.Num = 0;

                                    sumvaluedata = psum.Num;
                                    break;
                                }
                            }
                        }
                        if (psplf.L8 != "" && psplf.L8 != null)//变电站内的线路造价计算
                        {
                            foreach (Project_Sum psum in sumline)
                            {
                                if (psum.L1 == psplf.L9 && psum.S1 == psplf.L4)
                                {
                                    if (psum.Num.ToString() == null || psum.Num.ToString() == "")
                                        psum.Num = 0;

                                    sumvalueLine = psum.Num * double.Parse(psplf.L8);
                                    break;
                                }
                            }
                        }
                        psplf.L10 = Math.Round(sumvaluedata + sumvalueLine, 2);
                        if (psplf.L11 == "" || psplf.L11 == null)
                        {
                            psplf.L11 = "0";
                        }
                        psplf.L12 = Math.Round(psplf.L10 + double.Parse(psplf.L11), 2);
                    }
                }

                ddd = DateTime.Now;
                sss += " 12:" + ddd.ToString();//测试运算时间,可删除

                sss += " 13:" + ddd.ToString();//测试运算时间,可删除
                dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(PSP_PowerProValues_LangFang));
                //dataTable.DefaultView.Sort = "L4 desc";
                //dataTable.DefaultView.Sort = "Title desc";
                //dataTable.DefaultView.Sort = "CreateTime desc";
                ////foreach (DataRow rw in dataTable.Rows)
                ////{
                ////    string ss = rw["Code"].ToString();
                ////    LineInfo li = Common.Services.BaseService.GetOneByKey<LineInfo>(ss);
                ////if (li != null && li.EleID != "")
                ////{
                ////    rw["L3"] = li.LineName;
                ////    rw["L8"] = li.Length;
                ////    rw["L9"] = li.LineType;
                ////}
                ////substation li1 = Common.Services.BaseService.GetOneByKey<substation>(ss);
                ////if (li1 != null && li1.EleID != "")
                ////{
                ////    rw["L3"] = li1.EleName;
                ////    //rw["L5"] = li1.ObligateField2;
                ////    //rw["L2"] = li1.Number;
                ////    //rw["L6"] = li1.Burthen;
                ////}

                ////}
                treeList1.DataSource = dataTable;

                treeList1.Columns["L3"].Caption = "工程名称";
                treeList1.Columns["L3"].Width = 80;
                treeList1.Columns["L3"].OptionsColumn.AllowEdit = false;
                treeList1.Columns["L3"].OptionsColumn.AllowSort = false;
                treeList1.Columns["Title"].VisibleIndex = -1;
                treeList1.Columns["Title"].OptionsColumn.ShowInCustomizationForm = false;
                treeList1.Columns["Flag"].VisibleIndex = -1;
                treeList1.Columns["Flag"].SortOrder = System.Windows.Forms.SortOrder.None;
                treeList1.Columns["Flag"].OptionsColumn.ShowInCustomizationForm = false;
                treeList1.Columns["Flag2"].VisibleIndex = -1;
                treeList1.Columns["Flag2"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["CreateTime"].VisibleIndex = -1;
                treeList1.Columns["CreateTime"].OptionsColumn.ShowInCustomizationForm = false;
                treeList1.Columns["CreateTime"].SortOrder = System.Windows.Forms.SortOrder.None;

                treeList1.Columns["UpdateTime"].VisibleIndex = -1;
                treeList1.Columns["UpdateTime"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["UpdateTime"].VisibleIndex = -1;
                treeList1.Columns["UpdateTime"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["Code"].VisibleIndex = -1;
                treeList1.Columns["Code"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L1"].VisibleIndex = -1;
                treeList1.Columns["L1"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L2"].VisibleIndex = -1;
                treeList1.Columns["L2"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L11"].VisibleIndex = -1;
                treeList1.Columns["L11"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L12"].VisibleIndex = -1;
                treeList1.Columns["L12"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L13"].VisibleIndex = -1;
                treeList1.Columns["L13"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L14"].VisibleIndex = -1;
                treeList1.Columns["L14"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L15"].VisibleIndex = -1;
                treeList1.Columns["L15"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L16"].VisibleIndex = -1;
                treeList1.Columns["L16"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L17"].VisibleIndex = -1;
                treeList1.Columns["L17"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L18"].VisibleIndex = -1;
                treeList1.Columns["L18"].OptionsColumn.ShowInCustomizationForm = false;

                treeList1.Columns["L19"].VisibleIndex = -1;
                treeList1.Columns["L19"].OptionsColumn.ShowInCustomizationForm = false;
                treeList1.Columns["Remark"].VisibleIndex = -1;
                treeList1.Columns["Remark"].OptionsColumn.ShowInCustomizationForm = false;
                AddColumn2();
                PowerProYears psp_Year = new PowerProYears();
                psp_Year.Flag = typeFlag2;

                Application.DoEvents();

                LoadValues();
                TreeListColumn column = treeList1.Columns["L10"];
                TreeListColumn column1 = treeList1.Columns["L12"];
                for (int i = 0; i < treeList1.Nodes.Count; i++)
                {

                    CalculateNodesValue(treeList1.Nodes[i], column, column1);
                }
                treeList1.ExpandAll();
            }
            catch
            {

            }
        }
Example #8
0
 private bool SaveCellValue(string UID, string value)
 {
     PSP_PowerProValues_LangFang PowerValues = new PSP_PowerProValues_LangFang();
     PowerValues.ID = UID;
     try
     {
         PowerValues = (PSP_PowerProValues_LangFang)Common.Services.BaseService.GetObject("SelectPSP_PowerProValues_LangFangByID", PowerValues);
         PowerValues.L10 =double.Parse(value);
         Common.Services.BaseService.Update("UpdatePSP_PowerProValues_LangFangByID", PowerValues);
     }
     catch (Exception ex)
     {
         MsgBox.Show("保存数据出错:" + ex.Message);
         return false;
     }
     return true;
 }
Example #9
0
        private void InsertLineData1()
        {
            PowerEachList pel = this.ctrlPowerEachList1.FocusedObject;
            bool bl = true;
            string parentid = "";
            string id = "";
            string flag2 = "";
            TreeListNode tln = treeList1.FocusedNode;
            //if (tln != null)
            //{
            //    bl = false;
            //    try
            //    {
            //         parentid = tln["ParentID"].ToString();
            //         id = tln["ID"].ToString();
            //         flag2 = tln["Flag2"].ToString();
            //    }
            //    catch
            //    { }
            //}
            //else
               // {
                id = "0";
                flag2 = pel.UID;

            //}

            PSP_PowerProValues_LangFang z = new PSP_PowerProValues_LangFang();
            PowerProYears h = new PowerProYears();
            PowerProValues j = new PowerProValues();

            object obj = Services.BaseService.GetObject("SelectPowerProTypesList", "");

            try
            {
                DataTable dts = new DataTable();
                OpenFileDialog op = new OpenFileDialog();
                op.Filter = "Excel文件(*.xls)|*.xls";
                if (op.ShowDialog() == DialogResult.OK)
                {
                    dts = GetExcel(op.FileName);

                    for (int i = 1; i < dts.Rows.Count; i++)
                    {
                        if (dts.Rows[i][1].ToString().IndexOf("合计") >= 0)
                            continue;
                        z.ID = Guid.NewGuid().ToString();
                        string strflag = "";
                        foreach (DataColumn dc in dts.Columns)
                        {
                           strflag = dc.Caption.ToString();
                            try {
                            switch (strflag)
                            {
                                case "项目名称":
                                        z.Title = dts.Rows[i][dc.ColumnName].ToString();
                                    break;
                                case "工程名称":
                                        z.L3 = dts.Rows[i][dc.ColumnName].ToString();
                                    break;
                                case "电压等级":
                                    z.L4 = dts.Rows[i][dc.ColumnName].ToString();
                                    break;
                                case "主变台数":
                                    z.L5 = dts.Rows[i][dc.ColumnName].ToString();
                                    break;
                                case "单台容量(MVA)":
                                    z.L6 = dts.Rows[i][dc.ColumnName].ToString();
                                    break;
                                case "总容量(MVA)":
                                    z.IsConn = dts.Rows[i][dc.ColumnName].ToString();
                                    break;
                                case "建设形式":
                                     z.L7 = dts.Rows[i][dc.ColumnName].ToString();
                                    break;

                                case "线路长度(KM)":
                                    z.L8 = dts.Rows[i][dc.ColumnName].ToString();
                                    break;
                                case "导线型号":
                                    z.L9 = dts.Rows[i][dc.ColumnName].ToString();
                                    break;
                                //case "投资造价":
                                //    z.L11 = dts.Rows[i][dc.ColumnName].ToString();
                                //    break;
                                //case "造价比例":
                                //    z.L12 = dts.Rows[i][dc.ColumnName].ToString();
                                //    break;
                                case "标准造价(万元)":
                                    z.L10 =double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                    break;
                                case "造价调整(万元)":
                                    z.L11 = dts.Rows[i][dc.ColumnName].ToString();
                                    break;
                                case "工程总价(万元)":
                                    z.L12 = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                    break;
                                default:
                                    j.Value = dts.Rows[i][dc.ColumnName].ToString();
                                    j.TypeID = z.ID;
                                    j.Year = dc.ColumnName;
                                    j.TypeID1 = flag2;
                                    Services.BaseService.Update<PowerProValues>(j);
                                    break;
                            }
                        }
                        catch { }
                        }
                        z.Flag2 = flag2;
                        z.ParentID = "0";
                        //z.Flag = 1;
                   PSP_PowerProValues_LangFang lf=(PSP_PowerProValues_LangFang)Services.BaseService.GetObject("SelectPSP_PowerProValues_LangFangByObject",z);
                   if (lf == null)
                   {
                       Services.BaseService.Create<PSP_PowerProValues_LangFang>(z);
                   }
                 else
                   {
                       z.Code = lf.Code;
                       z.Flag = lf.Flag;
                       Services.BaseService.Update("UpdatePSP_PowerProValues_LangFangBytable", z);
                   }

                    }
            }
            ReLoadData();
               }
            catch { MsgBox.Show("导入格式不正确!"); }
        }
        private void FormAddInfo_LangFang_Load(object sender, EventArgs e)
        {
            if (isupdate == true)
            {

                PSP_PowerProValues_LangFang ppt = new PSP_PowerProValues_LangFang();
                ppt.ID = poweruid;
                ppt.Flag2 = flag;
                obj = Common.Services.BaseService.GetOneByKey<PSP_PowerProValues_LangFang>(ppt);
                OBJ = obj;
                isupdate = true;
                IList<PSP_PowerProValues_LangFang> list = new List<PSP_PowerProValues_LangFang>();
                list.Add(OBJ);
                this.vGridControl1.DataSource = list;
                UpDateInit();
            }

                if (isupdate == false)
                {
                    OBJ.ID = Guid.NewGuid().ToString();
                    OBJ.CreateTime = DateTime.Now;
                    OBJ.UpdateTime = DateTime.Now;
                    OBJ.ParentID = parentID;
                    OBJ.Flag2 = flag;
                    OBJ.L12 = 0;
                    OBJ.Flag = 2;
                    OBJ.L4 = "220";
                    OBJ.L5 = "1";
                    OBJ.L7 = "户内站";
                    OBJ.L11= "0";
                    OBJ.L10 = 0;
                    CreateInit();
                    IList<PSP_PowerProValues_LangFang> list = new List<PSP_PowerProValues_LangFang>();
                    list.Add(OBJ);
                    this.vGridControl1.DataSource = list;

                }

              //  this.电压等级.Properties.RowEdit.EditValueChanging+=new ChangingEventHandler(RowEdit_EditValueChanging1);
            this.电压等级.Properties.RowEdit.Click += new EventHandler(RowEdit_Click);
              //  this.电压等级.Properties.RowEdit.Click += new EventHandler(RowEdit_Click);
            this.主变台数及容量.Properties.RowEdit.Click +=new EventHandler(RowEdit_Click1);
            this.出线规模.Properties.RowEdit.Click += new EventHandler(RowEdit_Click2);
            this.接线形式.Properties.RowEdit.Click += new EventHandler(RowEdit_Click3);
            this.无功配置.Properties.RowEdit.Click += new EventHandler(RowEdit_Click4);
            this.投资造价.Properties.RowEdit.Click += new EventHandler(RowEdit_Click5);
            this.造价比例.Properties.RowEdit.Click += new EventHandler(RowEdit_Click6);
            this.投资造价.Properties.RowEdit.EditValueChanged += new EventHandler(RowEdit_EditValueChanged);
            this.造价比例.Properties.RowEdit.EditValueChanging += new ChangingEventHandler(RowEdit_EditValueChanging);

            LineInfo li22 = Common.Services.BaseService.GetOneByKey<LineInfo>(powerid);
            if (li22 != null || OBJ.Flag == 1)
            {
                isline = true;
            }
            substation sb = Common.Services.BaseService.GetOneByKey<substation>(powerid);
            if (sb != null || OBJ.Flag == 2)
            {
                isPower = true;
            }
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            //  string z="自定义列";
            type = psp_Year.Year = spinEdit1.Text;
            psp_Year.Flag = flag2;
            if (type.ToString() == "")
            {
                MsgBox.Show("类别名称不能为空");
                return;

            }

            try
            {

                if (!IsUpdate)
                {

                    if (Common.Services.BaseService.GetObject("SelectPowerProYearsByYearFlag", psp_Year) == null)
                    {
                        try
                        {
                            Common.Services.BaseService.Create<PowerProYears>(psp_Year);
                            this.DialogResult = DialogResult.OK;
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show("出错啦:" + ex.Message);
                        }
                    }
                    else
                    {
                        MsgBox.Show("此分类已经存在,请重新输入!");
                    }
                }
                else
                {
                    try
                    {

                        PSP_PowerProValues_LangFang psp_Type = new PSP_PowerProValues_LangFang();
                        psp_Type.Flag2 = type1;
                        IList<PSP_PowerProValues_LangFang> listTypes = new List<PSP_PowerProValues_LangFang>();
                        try
                        {
                            listTypes = Common.Services.BaseService.GetList<PSP_PowerProValues_LangFang>("SelectPSP_PowerProValues_LangFangByFlag2", psp_Type);
                        }
                        catch (Exception ex)
                        { MsgBox.Show(ex.Message); }

                        foreach (PSP_PowerProValues_LangFang pstt in listTypes)
                        {
                            PowerProValues psv = new PowerProValues();
                            psv.TypeID = pstt.ID;
                            psv.Year = psp_Year.Year;
                            psv.Value = year2;
                            psv.TypeID1 = type1;
                            Common.Services.BaseService.Update("UpdatePowerProValuesByYear1", psv);
                        }

                        Common.Services.BaseService.Update<PowerProYears>(psp_Year);
                        this.DialogResult = DialogResult.OK;
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("出错啦:" + ex.Message);
                    }

                }
            }
            catch(Exception ex)
            {
                MsgBox.Show("出错啦:" + ex.Message);
            }
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < te.Length; i++)
            {
                SaveCellValue(te[i].Name.Replace("Text", ""), poweruid, te[i].Text.Trim());
            }

            if (isline)
            {
                try
                {

                    LineInfo li=Common.Services.BaseService.GetOneByKey<LineInfo>(powerid);

                    if (li != null)
                    {
                        li.LineName = cb0.Text;
                        li.Voltage = cb1.Text;
                        li.Length = tt4.Text;
                        li.LineType =cb5.Text;
                        Common.Services.BaseService.Update<LineInfo>(li);
                    }

                }
                catch { }
            }
            if (isPower)
            {
                try
                {
                    substation sb = Common.Services.BaseService.GetOneByKey<substation>(powerid);
                    Substation_Info sub =  new Substation_Info();
                    sub.Code = powerid;
                    Substation_Info sbinfo = (Substation_Info)Common.Services.BaseService.GetObject("SelectSubstation_InfoByCode", sub);
                    if(sbinfo!=null)
                    {
                        sbinfo.L2 = double.Parse( cb3.Text);
                        sbinfo.L3 =int.Parse( cb2.Text);
                         Common.Services.BaseService.Update("UpdateSubstation_InfoByUID", sub);
                    }

                    if (sb != null)
                    {
                        try
                        {
                            sb.EleName = cb0.Text;
                            sb.ObligateField1 = cb1.Text;
                        }
                        catch { }

                        Common.Services.BaseService.Update<substation>(sb);
                    }
                }
                catch { }
            }

            try
            {
                PSP_PowerProValues_LangFang ppts = new PSP_PowerProValues_LangFang();
                ppts.ID = poweruid;
                ppts.Flag2 = flag;

                PSP_PowerProValues_LangFang ppt1 = Common.Services.BaseService.GetOneByKey<PSP_PowerProValues_LangFang>(ppts);
                try
                {
                    ppt1.L3 = cb0.Text.ToString();
                    ppt1.L4 = cb1.Text.ToString();
                    ppt1.L5 = cb2.Text.ToString();
                    ppt1.L6 = cb3.Text.ToString();
                    ppt1.L7 = cb4.Text.ToString();
                    ppt1.L8 = tt4.Text.ToString();
                    ppt1.L9 = cb5.Text.ToString();
                    ppt1.L10 = double.Parse(tt5.Text.ToString());
                    ppt1.L11 =lookupedit;
                    ppt1.L12 = double.Parse(tt6.Text.ToString());
                }
                catch { }
                Common.Services.BaseService.Update<PSP_PowerProValues_LangFang>(ppt1);
            }
            catch { }

            this.DialogResult = DialogResult.OK;
        }
        private void FrmEditProject_Load(object sender, EventArgs e)
        {
            SetData();
            string q1 = "";
            string q2 = "";
            string q3 = "";
            string q4 = "";
            string q5 = "";
            string q6 = "";
            string q7 = "";
            string q8 = "";
            string q9 = "";
            string q10 = "";
            string q11 = "";
            string q12 = "";

            int t1 = 0;

            PSP_PowerProValues_LangFang ppt = new PSP_PowerProValues_LangFang();
            ppt.ID = poweruid;
            ppt.Flag2 = flag;

            PSP_PowerProValues_LangFang ps = Common.Services.BaseService.GetOneByKey<PSP_PowerProValues_LangFang>(ppt);
            if (ps != null)
            {
                groupBox1.Text = ps.Title;
                powerid = ps.Code;
                t1 = ps.Flag;

               // q1 = ps.L1;
               // q2 = ps.L2;
                q3 = ps.L3;
                q4 = ps.L4;
                q5 = ps.L5;
                q6 = ps.L6;
                q7 = ps.L7;
                q8 = ps.L8;
                q9 = ps.L9;
                q10 = ps.L10.ToString();
                q11 = ps.L11;
                q12 = ps.L12.ToString();

            }

            LineInfo li22 = Common.Services.BaseService.GetOneByKey<LineInfo>(powerid);
            if (li22 != null || t1==1)
            {
                isline = true;
            }

            substation sb = Common.Services.BaseService.GetOneByKey<substation>(powerid);
            if (sb != null || t1 == 2)
            {
                isPower = true;
            }

            PowerProValues ppv = new PowerProValues();
            ppv.TypeID = poweruid;
            ppv.TypeID1 = flag;
            IList<PowerProValues> listValues = Common.Services.BaseService.GetList<PowerProValues>("SelectPowerProValuesList", ppv);

            PowerProYears pps = new PowerProYears();
            pps.Flag = flag;
            IList<PowerProYears> li = Common.Services.BaseService.GetList<PowerProYears>("SelectPowerProYearsListByFlag", pps);

            lb=new Label[li.Count];
            te=new TextEdit[li.Count];

            int i=0;

            //if (!isPower)
               // {
                ////lt1.Text = "�豸����:";
                ////lt1.Location = new Point(52, 27 + 33 * i);
                ////groupBox1.Controls.Add(lt1);

                ////tt1 = new TextEdit();
                ////tt1.Location = new Point(157, 26 + 33 * i);
                ////tt1.Size = new Size(231, 21);
                ////tt1.TextChanged += new EventHandler(tt1_TextChanged);
                ////tt1.Properties.DisplayFormat.FormatString = "n4";
                ////tt1.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                ////tt1.Properties.EditFormat.FormatString = "n4";
                ////tt1.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                ////tt1.Properties.Mask.EditMask = "#####0.####";
                ////tt1.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;

                ////groupBox1.Controls.Add(tt1);

                ////i++;

                ////lt2.Text = "̨��:";
                ////lt2.Location = new Point(52, 27 + 33 * i);
                ////groupBox1.Controls.Add(lt2);

                ////tt2 = new TextEdit();
                ////tt2.Location = new Point(157, 26 + 33 * i);
                ////tt2.Size = new Size(231, 21);
                ////groupBox1.Controls.Add(tt2);

                ////i++;
               // }

            //if (!isline)
            {
                lt3.Text = "�� �� �� �� :";
                lt3.Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lt3);

               // tt3 = new TextEdit();
                cb0.Location = new Point(157, 26 + 33 * i);
                cb0.Size = new Size(231, 21);

                cb0.Properties.DisplayFormat.FormatString = "n0";
                cb0.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.None;
                cb0.Properties.EditFormat.FormatString = "n0";
                cb0.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.None;
               // cb0.Properties.Mask.EditMask = "########";
                cb0.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None;

                groupBox1.Controls.Add(cb0);

                i++;

                lt4.Text = "�� ѹ �� �� :";
                lt4.Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lt4);

               // tt4 = new TextEdit();
                cb1.Location = new Point(157, 26 + 33 * i);
                cb1.Size = new Size(231, 21);

                cb1.Properties.DisplayFormat.FormatString = "n4";
                cb1.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.None;
                cb1.Properties.EditFormat.FormatString = "n4";
                cb1.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.None;
               // cb1.Properties.Mask.EditMask = "#####0.####";
                cb1.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None;

                groupBox1.Controls.Add(cb1);
                i++;

                lt5.Text = "�� �� ̨ �� :";
                lt5.Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lt5);

              //  tt5 = new TextEdit();
                cb2.Location = new Point(157, 26 + 33 * i);
                cb2.Size = new Size(231, 21);

                cb2.Properties.DisplayFormat.FormatString = "####.##";
                cb2.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                cb2.Properties.EditFormat.FormatString = "####.##";
                cb2.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
               // cb2.Properties.Mask.EditMask = "P2";
                cb2.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;

                groupBox1.Controls.Add(cb2);
                i++;

                lt6.Text = "��̨������MVA��:";
                lt6.Location = new Point(50, 27 + 33 * i);
                lt6.Width = 105;
                groupBox1.Controls.Add(lt6);

                //tt6 = new TextEdit();
                cb3.Location = new Point(157, 26 + 33 * i);
                cb3.Size = new Size(231, 21);

                cb3.Properties.DisplayFormat.FormatString = "n4";
                cb3.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.None;
                cb3.Properties.EditFormat.FormatString = "n4";
                cb3.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.None;
              //  cb3.Properties.Mask.EditMask = "#####0.####";
                cb3.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None;

                groupBox1.Controls.Add(cb3);

                i++;

                lt7.Text = "�� �� �� ʽ :";
                lt7.Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lt7);

                //tt6 = new TextEdit();
                cb4.Location = new Point(157, 26 + 33 * i);
                cb4.Size = new Size(231, 21);

                cb4.Properties.DisplayFormat.FormatString = "n4";
                cb4.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.None;
                cb4.Properties.EditFormat.FormatString = "n4";
                cb4.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.None;
               // cb4.Properties.Mask.EditMask = "#####0.####";
                cb4.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None;

                groupBox1.Controls.Add(cb4);

                i++;

                lt8.Text = "��·���ȣ�KM��:";
                lt8.Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lt8);

                //tt6 = new TextEdit();
                tt4.Location = new Point(157, 26 + 33 * i);
                tt4.Size = new Size(231, 21);

                tt4.Properties.DisplayFormat.FormatString = "n4";
                tt4.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.None;
                tt4.Properties.EditFormat.FormatString = "n4";
                tt4.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.None;
              //  tt4.Properties.Mask.EditMask = "#####0.####";
                tt4.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None;

                groupBox1.Controls.Add(tt4);

                i++;

                lt9.Text = "�� �� �� �� :";
                lt9.Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lt9);

                //tt6 = new TextEdit();
                cb5.Location = new Point(157, 26 + 33 * i);
                cb5.Size = new Size(231, 21);

                cb5.Properties.DisplayFormat.FormatString = "n4";
                cb5.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.None;
                cb5.Properties.EditFormat.FormatString = "n4";
                cb5.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.None;
               // cb5.Properties.Mask.EditMask = "#####0.####";
                cb5.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None;

                groupBox1.Controls.Add(cb5);

                i++;

                Project_Sum sum = new Project_Sum();
                sum.S5 = islineflag;
                sum.S1 = q4;
                IList<Project_Sum> list = Services.BaseService.GetList<Project_Sum>("SelectProject_SumByS1andS5",sum);
                upedit.Properties.DataSource = list;
                LookUpColumnInfo a = new LookUpColumnInfo();
                a.FieldName = "T3";
                a.Caption = "������ʽ";
                LookUpColumnInfo c = new LookUpColumnInfo();
                c.FieldName = "T2";
                c.Caption = "���߹�ģ";
                LookUpColumnInfo b = new LookUpColumnInfo();
                b.FieldName = "T1";
                b.Caption = "����̨��������";
                LookUpColumnInfo d = new LookUpColumnInfo();
                d.Caption = "��̬Ͷ��";
                d.FieldName = "Num";
                LookUpColumnInfo nn = new LookUpColumnInfo();
                nn.FieldName = "Name";
                nn.Caption = "���";
                LookUpColumnInfo f = new LookUpColumnInfo();
                f.FieldName = "Type";
                f.Caption = "����";
                upedit.Properties.Columns.Add(f);
                upedit.Properties.Columns.Add(nn);
                upedit.Properties.Columns.Add(b);
                upedit.Properties.Columns.Add(c);
                upedit.Properties.Columns.Add(a);
                upedit.Properties.Columns.Add(d);
                upedit.Properties.DisplayMember = "Num";
                //upedit.Properties.SearchMode = SearchMode.AutoComplete;
                //upedit.Properties.AutoSearchColumnIndex = 5;
                upedit.Properties.DropDownRows =5;
                upedit.Properties.PopupWidth = 500;
                upedit.Properties.ShowHeader = true;

                lt10.Text = "Ͷ �� �� �� :";
                lt10.Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lt10);
                upedit.Location = new Point(157, 26 + 33 * i);
                upedit.Size = new Size(231, 21);
                upedit.Properties.DisplayFormat.FormatString = "n4";
                upedit.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                upedit.Properties.EditFormat.FormatString = "n4";
                upedit.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                upedit.Properties.Mask.EditMask = "###############0.####";
                upedit.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
                upedit.Properties.AllowNullInput=DevExpress.Utils.DefaultBoolean.True;
                upedit.TextChanged += new EventHandler(upedit_TextChanged);
                groupBox1.Controls.Add(upedit);

                i++;

                lt11.Text = "�� �� �� �� :";
                lt11.Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lt11);

                //tt6 = new TextEdit();
                tt6.Location = new Point(157, 26 + 33 * i);
                tt6.Size = new Size(231, 21);

                tt6.Properties.DisplayFormat.FormatString = "n4";
                tt6.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                tt6.Properties.EditFormat.FormatString = "n4";
                tt6.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                tt6.Properties.Mask.EditMask = "###############0.####";
                tt6.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
                tt6.TextChanged += new EventHandler(tt6_TextChanged);
                groupBox1.Controls.Add(tt6);

                i++;

                lt12.Text = "�� �� �� �� :";
                lt12.Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lt12);

                //tt6 = new TextEdit();
                tt5.Location = new Point(157, 26 + 33 * i);
                tt5.Size = new Size(231, 21);

                tt5.Properties.DisplayFormat.FormatString = "n4";
                tt5.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                tt5.Properties.EditFormat.FormatString = "n4";
                tt5.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                tt5.Properties.Mask.EditMask = "###############0.####";
                tt5.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;

                groupBox1.Controls.Add(tt5);

                i++;
            }

            int j = 0;
            foreach (PowerProYears ppy in li)
            {
                lb[j] = new Label();
                lb[j].Name = "Label" + ppy.Year;
                lb[j].Text = ppy.Year + ":";
                lb[j].Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(lb[j]);

                te[j] = new TextEdit();
                te[j].Name = "Text" + ppy.Year;
                te[j].Location = new Point(157, 26 + 33 * i);
                te[j].Size = new Size(231, 21);
                groupBox1.Controls.Add(te[j]);

                foreach (PowerProValues ppy1 in listValues)
                {
                    if (ppy.Year == ppy1.Year)
                        te[j].Text = ppy1.Value;
                }
                j++;
                i++;
            }

            if (isline)
            {
                try
                {
                  // cb5.Properties.Items.Contains(q9.ToString());

                    //tt1.Text = q3.ToString();
                    //tt2.Text = q4.ToString();

                    //if (li22 != null)
                    //{
                    //    tt1.Text = li22.Length;
                    //    tt2.Text = li22.LineType;
                    //}
                }
                catch { }

            }
            if (isPower)
            {
                try
                {
                    ////tt3.Text = q1.ToString();
                    //tt4.Text = q4.ToString();
                    //tt5.Text = q5.ToString();
                    //tt6.Text = q6.ToString();

                    //if (sb != null)
                    //{
                    //    tt5.Text = sb.Number.ToString();
                    //    tt4.Text = sb.ObligateField2;
                    //    tt6.Text = sb.Burthen.ToString();
                    //}

                }
                catch { }
            }

            PSP_PowerProValues_LangFang pplf = new PSP_PowerProValues_LangFang();

            pplf.Flag2 = flag;

            IList<PSP_PowerProValues_LangFang> plfs = Common.Services.BaseService.GetList<PSP_PowerProValues_LangFang>("SelectPSP_PowerProValues_LangFangByFlag2OrderL3", pplf);

            tt4.Text = q8.ToString();
            tt5.Text = q10.ToString();
            tt6.Text = q12.ToString();

            if (plfs.Count == 0)
            {
                cb0.Text = "";
            }
            foreach (PSP_PowerProValues_LangFang pv in plfs)
            {
                if(pv.L3!=""&&pv.L3.Length>0)
                cb0.Properties.Items.Add(pv.L3);
            }
            cb0.Text = q3.ToString();
            cb1.Text = q4.ToString();
            cb2.Text = q5.ToString();
            cb3.Text = q6.ToString();
            cb4.Text = q7.ToString();
            cb5.Text = q9.ToString();
            lookupedit = q11;
            upedit.Properties.NullText = q11;
            groupBox1.Size = new Size(434, 40+ 33 * i);
            simpleButton1.Location = new Point(296, 60 + 33 * i);
            simpleButton2.Location = new Point(389, 60 + 33 * i);
            this.Size = new Size(490, 130 + 33 * i);
        }