コード例 #1
0
        private bool SaveCellValue(string year, string typeID, string value)
        {
            PowerValues PValues = new PowerValues();

            try
            {
                PValues.TypeID = int.Parse(typeID);
            }
            catch
            {
            }
            if (value == "")
            {
                value = "0";
            }
            PValues.Value = double.Parse(value);
            PValues.Year  = int.Parse(year);

            try
            {
                Common.Services.BaseService.Update <PowerValues>(PValues);
            }
            catch (Exception ex)
            {
                MsgBox.Show("保存数据出错:" + ex.Message);
                return(false);
            }
            return(true);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: github188/myitoppsp
        private bool SaveCellValue(int year, int typeID, double value)
        {
            PowerValues PowerValues = new PowerValues();

            PowerValues.TypeID = typeID;
            PowerValues.Value  = value;
            PowerValues.Year   = year;

            try
            {
                Common.Services.BaseService.Update <PowerValues>(PowerValues);
            }
            catch (Exception ex)
            {
                MsgBox.Show("保存数据出错:" + ex.Message);
                return(false);
            }
            return(true);
        }
コード例 #3
0
        public String Create([FromBody] JObject character)
        {
            //return SelectJsonToken(character, "power_values")[0].ToString();


            Boolean found = false;

            try
            {
                String name = SelectStrToken(character, "name");
                if (GetByName(name) != "[]")
                {
                    found = true;
                }
            }
            catch
            {
            }
            if (!found)
            {
                int?intelligence = null;
                int?strength     = null;
                int?speed        = null;
                int?durability   = null;
                int?power        = null;
                int?combat       = null;
                int?total        = null;
                int?year         = null;

                List <PowerValues> power_values = new List <PowerValues>();
                foreach (JToken item in SelectJsonToken(character, "power_values"))
                {
                    //String power_name = item;
                    PowerValues powervalue = new PowerValues();
                    powervalue.power_name = SelectStrToken(JObject.Parse(item.ToString()), "power_name");

                    power_values.Add(powervalue);
                }

                intelligence = SelectIntToken(character, "stats.intelligence");
                strength     = SelectIntToken(character, "stats.strength");
                speed        = SelectIntToken(character, "stats.speed");
                durability   = SelectIntToken(character, "stats.durability");
                power        = SelectIntToken(character, "stats.power");
                combat       = SelectIntToken(character, "stats.combat");
                total        = SelectIntToken(character, "stats.total");
                year         = SelectIntToken(character, "year");


                var pj = new Character
                {
                    name      = SelectStrToken(character, "name"),
                    universe  = SelectStrToken(character, "universe"),
                    alignment = SelectStrToken(character, "alignment"),
                    year      = year,
                    status    = SelectStrToken(character, "status"),
                    race      = SelectStrToken(character, "race"),
                    gender    = SelectStrToken(character, "gender"),
                    stats     = new Stats
                    {
                        intelligence = intelligence,
                        strength     = strength,
                        speed        = speed,
                        durability   = durability,
                        power        = power,
                        combat       = combat,
                        total        = total,
                    },
                    power_values = power_values
                };



                pj.Save();
                return(character.SelectToken("name").ToString() + " creado!");
            }
            else if (found)
            {
                return("Ya existe un personaje con el nombre " + character.SelectToken("name").ToString());
            }

            return(character.SelectToken("name").ToString());
        }
コード例 #4
0
        public String Update([FromBody] JObject character)
        {
            Boolean found = false;
            String  id    = "";

            id    = SelectStrToken(character, "_id");
            found = true;


            var result = DB.Find <Character>().One(id);

            if (!found)
            {
                return("No se ha encontrado el personaje.");
            }
            else if (found)
            {
                String Name      = "";
                String Universe  = "";
                String Alignment = "";
                String Race      = "";
                String Gender    = "";
                String Status    = "";

                int?intelligence = -1;
                int?strength     = -1;
                int?speed        = -1;
                int?durability   = -1;
                int?power        = -1;
                int?combat       = -1;
                int?total        = -1;
                int?year         = -1;

                List <PowerValues> power_values = new List <PowerValues>();
                Boolean            nopowers     = true;
                try
                {
                    foreach (JToken item in SelectJsonToken(character, "power_values"))
                    {
                        //String power_name = item;
                        PowerValues powervalue = new PowerValues();
                        powervalue.power_name = SelectStrToken(JObject.Parse(item.ToString()), "power_name");

                        power_values.Add(powervalue);
                    }
                    nopowers = false;
                }
                catch
                {
                    nopowers = true;
                }


                Name      = SelectStrToken(character, "name").ToString();
                Universe  = SelectStrToken(character, "universe").ToString();
                Alignment = SelectStrToken(character, "alignment").ToString();
                Race      = SelectStrToken(character, "race").ToString();
                Gender    = SelectStrToken(character, "gender").ToString();
                Status    = SelectStrToken(character, "status").ToString();



                intelligence = SelectIntToken(character, "stats.intelligence");
                strength     = SelectIntToken(character, "stats.strength");
                speed        = SelectIntToken(character, "stats.speed");
                durability   = SelectIntToken(character, "stats.durability");
                power        = SelectIntToken(character, "stats.power");
                combat       = SelectIntToken(character, "stats.combat");
                total        = SelectIntToken(character, "stats.total");
                year         = SelectIntToken(character, "year");



                var pj = result;


                if (Name != "")
                {
                    pj.name = Name;
                }
                if (Universe != "")
                {
                    pj.universe = Universe;
                }
                if (Alignment != "")
                {
                    pj.alignment = Alignment;
                }
                if (Race != "")
                {
                    pj.race = Race;
                }
                if (Gender != "")
                {
                    pj.gender = Gender;
                }
                if (Status != "")
                {
                    pj.status = Status;
                }
                if (!nopowers)
                {
                    pj.power_values = power_values;
                }
                if (intelligence != null && strength != null && total != null && speed != null && durability != null && power != null && combat != null)
                {
                    pj.stats = new Stats
                    {
                        intelligence = intelligence,
                        strength     = strength,
                        speed        = speed,
                        durability   = durability,
                        power        = power,
                        combat       = combat,
                        total        = total,
                    }
                }
                ;

                if (year != null)
                {
                    pj.year = year;
                }

                pj.Save();
            }

            return("personaje con id " + id + " actualizado!");
        }
コード例 #5
0
        public String AdvancedSearch([FromBody] JObject character)
        {
            String Name      = "";
            String Universe  = "";
            String Alignment = "";
            String Race      = "";
            String Gender    = "";
            //String Stats = "";
            String Status       = "";
            int?   intelligence = -1;
            int?   strength     = -1;
            int?   speed        = -1;
            int?   durability   = -1;
            int?   power        = -1;
            int?   combat       = -1;
            int?   total        = -1;
            int?   year         = -1;

            List <PowerValues> power_values = new List <PowerValues>();
            Boolean            nopowers     = true;

            try {
                foreach (JToken item in SelectJsonToken(character, "power_values"))
                {
                    //String power_name = item;
                    PowerValues powervalue = new PowerValues();
                    powervalue.power_name = SelectStrToken(JObject.Parse(item.ToString()), "power_name");

                    power_values.Add(powervalue);
                }
                nopowers = false;
            }
            catch {
                nopowers = true;
            }


            //try
            //{
            Name      = SelectStrToken(character, "name");//character.SelectToken("name").ToString();
            Universe  = SelectStrToken(character, "universe");
            Alignment = SelectStrToken(character, "alignment");
            Race      = SelectStrToken(character, "race");
            Gender    = SelectStrToken(character, "gender");
            //Stats = SelectStrToken(character, "stats");


            intelligence = SelectIntToken(character, "stats.intelligence");
            strength     = SelectIntToken(character, "stats.strength");
            speed        = SelectIntToken(character, "stats.speed");
            durability   = SelectIntToken(character, "stats.durability");
            power        = SelectIntToken(character, "stats.power");
            combat       = SelectIntToken(character, "stats.combat");
            total        = SelectIntToken(character, "stats.total");
            year         = SelectIntToken(character, "year");

            /*foreach(PowerValues item in power_values)
             * {
             *  if()
             * }*/
            //return nopowers.ToString();
            //return power_values.ToJson().ToString();
            //var result = DB.Find<Character>().Many(p => p.power_values.Contains(power_values[0]));
            // return result.ToJson().Replace("ObjectId(", "").Replace("ISODate(", "").Replace(")", "");

            if (power_values.Count() == 2)
            {
                var result = DB.Find <Character>().Many(p => ((p.name.ToLower() == Name.ToLower() || Name == "") && (p.universe.ToLower() == Universe.ToLower() || Universe == "") && (p.alignment.ToLower() == Alignment.ToLower() || Alignment == "") && (p.race.ToLower() == Race.ToLower() || Race == "") && (p.gender.ToLower() == Gender.ToLower() || Gender == "") &&
                                                              (p.stats.intelligence == intelligence || intelligence == null) && (p.stats.strength == strength || strength == null) && (p.stats.speed == speed || speed == null) && (p.stats.durability == durability || durability == null) && (p.stats.power == power || power == null) && (p.stats.combat == combat || combat == null) && (p.stats.total == total || total == null) &&
                                                              (p.status.ToLower() == Status.ToLower() || Status == "") && (p.year == year || year == null) &&
                                                              p.power_values.Contains(power_values[0]) && p.power_values.Contains(power_values[1])));

                return(result.ToJson().Replace("ObjectId(", "").Replace("ISODate(", "").Replace(")", ""));
            }
            else if (power_values.Count() == 1)
            {
                var result = DB.Find <Character>().Many(p => ((p.name.ToLower() == Name.ToLower() || Name == "") && (p.universe.ToLower() == Universe.ToLower() || Universe == "") && (p.alignment.ToLower() == Alignment.ToLower() || Alignment == "") && (p.race.ToLower() == Race.ToLower() || Race == "") && (p.gender.ToLower() == Gender.ToLower() || Gender == "") &&
                                                              (p.stats.intelligence == intelligence || intelligence == null) && (p.stats.strength == strength || strength == null) && (p.stats.speed == speed || speed == null) && (p.stats.durability == durability || durability == null) && (p.stats.power == power || power == null) && (p.stats.combat == combat || combat == null) && (p.stats.total == total || total == null) &&
                                                              (p.status.ToLower() == Status.ToLower() || Status == "") && (p.year == year || year == null) &&
                                                              p.power_values.Contains(power_values[0])));

                return(result.ToJson().Replace("ObjectId(", "").Replace("ISODate(", "").Replace(")", ""));
            }
            else if (power_values.Count() == 0)
            {
                var result = DB.Find <Character>().Many(p => ((p.name.ToLower() == Name.ToLower() || Name == "") && (p.universe.ToLower() == Universe.ToLower() || Universe == "") && (p.alignment.ToLower() == Alignment.ToLower() || Alignment == "") && (p.race.ToLower() == Race.ToLower() || Race == "") && (p.gender.ToLower() == Gender.ToLower() || Gender == "") &&
                                                              (p.stats.intelligence == intelligence || intelligence == null) && (p.stats.strength == strength || strength == null) && (p.stats.speed == speed || speed == null) && (p.stats.durability == durability || durability == null) && (p.stats.power == power || power == null) && (p.stats.combat == combat || combat == null) && (p.stats.total == total || total == null) &&
                                                              (p.status.ToLower() == Status.ToLower() || Status == "") && (p.year == year || year == null)));

                return(result.ToJson().Replace("ObjectId(", "").Replace("ISODate(", "").Replace(")", ""));
            }
            else
            {
                return("Solo se permite filtrar por un máximo de 2 poderes.");
            }
        }
コード例 #6
0
        private void FrmEditProject_Load(object sender, EventArgs e)
        {
            string q0  = "";
            string q1  = "";
            string q2  = "";
            string q3  = "";
            double?q4  = null;
            string q5  = "";
            string q6  = "";
            string q7  = "";
            string q8  = "";
            string q9  = "";
            string q10 = "";
            string q11 = "";
            string q12 = "";
            string q13 = "";
            string q14 = "";
            string q15 = "";
            string q16 = "";
            string q17 = "";
            string q18 = "";
            string q19 = "";
            string q20 = "";
            string q21 = "";
            string q22 = "";
            string q23 = "";
            string q24 = "";


            int t1 = 0;

            PSP_PowerTypes_Liao ppt = new PSP_PowerTypes_Liao();

            try
            {
                ppt.ID = int.Parse(poweruid);
            }
            catch { }
            ppt.Flag2 = flag;

            PSP_PowerTypes_Liao ps = (PSP_PowerTypes_Liao)Common.Services.BaseService.GetOneByKey <PSP_PowerTypes_Liao>(ppt);

            // if (ps != null)
            try
            {
                groupBox1.Text = ps.Title;
                q0             = ps.Title;
                t1             = ps.Flag;
                q1             = ps.JianSheXingZhi;
                q2             = ps.RongLiang;
                q3             = ps.ChangDu;
                dt             = ps.CreatTime;
                if (ps.TouZiZongEr.ToString() != "")
                {
                    q4 = double.Parse(ps.TouZiZongEr);
                }
                if (ps.S1 == "" || ps.S1 == null)
                {
                    q5 = "";
                }
                else
                {
                    q5 = ps.S1;
                }

                if (ps.S2 != "" && ps.S2 != null)
                {
                    q6 = ps.S2;
                }

                if (ps.S3 != "" && ps.S3 != null)
                {
                    q7 = ps.S3;
                }

                if (ps.S4 != "" && ps.S4 != null)
                {
                    q8 = ps.S4;
                }


                if (ps.S5 != "" && ps.S5 != null)
                {
                    q9 = ps.S5;
                }

                if (ps.S6 != "" && ps.S6 != null)
                {
                    q10 = ps.S6;
                }

                if (ps.S7 != "" && ps.S7 != null)
                {
                    q11 = ps.S7;
                }


                if (ps.S8 != "" && ps.S8 != null)
                {
                    q12 = ps.S8;
                }

                if (ps.S9 != "" && ps.S9 != null)
                {
                    q13 = ps.S9;
                }

                if (ps.S10 != "" && ps.S10 != null)
                {
                    q14 = ps.S10;
                }

                if (ps.S11 != "" && ps.S11 != null)
                {
                    q15 = ps.S11;
                }

                if (ps.S12 != "" && ps.S12 != null)
                {
                    q16 = ps.S12;
                }


                if (ps.S13 != "" && ps.S13 != null)
                {
                    q17 = ps.S13;
                }

                if (ps.S14 != "" && ps.S14 != null)
                {
                    q18 = ps.S14;
                }

                if (ps.S15 != "" && ps.S15 != null)
                {
                    q19 = ps.S15;
                }

                if (ps.S16 != "" && ps.S16 != null)
                {
                    q20 = ps.S16;
                }

                if (ps.S17 != "" && ps.S17 != null)
                {
                    q21 = ps.S17;
                }


                if (ps.S18 != "" && ps.S18 != null)
                {
                    q22 = ps.S18;
                }


                if (ps.S19 != "" && ps.S19 != null)
                {
                    q23 = ps.S19;
                }


                if (ps.S20 != "" && ps.S20 != null)
                {
                    q24 = ps.S20;
                }
            }
            catch { }
            ac1.Add(q5);
            ac1.Add(q6);
            ac1.Add(q7);
            ac1.Add(q8);
            ac1.Add(q9);
            ac1.Add(q10);
            ac1.Add(q11);
            ac1.Add(q12);
            ac1.Add(q13);
            ac1.Add(q14);
            ac1.Add(q15);
            ac1.Add(q16);
            ac1.Add(q17);
            ac1.Add(q18);
            ac1.Add(q19);
            ac1.Add(q20);
            ac1.Add(q21);
            ac1.Add(q22);
            ac1.Add(q23);
            ac1.Add(q24);


            PowerValues ppv = new PowerValues();

            if (ps == null)
            {
                ppv.TypeID = -1;
            }
            else
            {
                ppv.TypeID = ps.ID;
            }
            //ppv.TypeID1 = flag;
            IList <PowerValues> listValues = Common.Services.BaseService.GetList <PowerValues>("SelectPowerValuesList", ppv);

            PowerYears pps = new PowerYears();

            pps.Flag = flag;
            IList <PowerYears> li = Common.Services.BaseService.GetList <PowerYears>("SelectPowerYearsListByFlagSortYear", pps);

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

            int i = 0;

            lt3.Text     = "项目名称:";
            lt3.Location = new Point(52, 27 + 33 * i);
            groupBox1.Controls.Add(lt3);

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

            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++;

            lt4.Text     = "变电容量:";
            lt4.Location = new Point(52, 27 + 33 * i);
            groupBox1.Controls.Add(lt4);

            tt4          = 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.Numeric;
            tt4.Properties.EditFormat.FormatString    = "n4";
            tt4.Properties.EditFormat.FormatType      = DevExpress.Utils.FormatType.Numeric;
            tt4.Properties.Mask.EditMask = "###########0.####";
            tt4.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;


            groupBox1.Controls.Add(tt4);

            i++;
            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.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++;

            lt6.Text     = "总投资(万元):";
            lt6.Location = new Point(52, 27 + 33 * i);
            groupBox1.Controls.Add(lt6);

            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;

            groupBox1.Controls.Add(tt6);

            i++;


            int j = 0;

            foreach (PowerYears 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);
                te[j].Properties.DisplayFormat.FormatString = "n4";
                te[j].Properties.DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Numeric;
                te[j].Properties.EditFormat.FormatString    = "n4";
                te[j].Properties.EditFormat.FormatType      = DevExpress.Utils.FormatType.Numeric;
                te[j].Properties.Mask.EditMask = "##########0.####";
                te[j].Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
                groupBox1.Controls.Add(te[j]);
                if (listValues.Count > 0)
                {
                    foreach (PowerValues ppy1 in listValues)
                    {
                        if (ppy.Year == ppy1.Year)
                        {
                            te[j].Text = ppy1.Value.ToString();
                        }
                    }
                }
                j++;
                i++;
            }


            PowerSubstationLine psl = new PowerSubstationLine();

            psl.Flag  = "1";
            psl.Type  = flag;
            psl.Type2 = type;

            IList <PowerSubstationLine> lli = Itop.Client.Common.Services.BaseService.GetList <PowerSubstationLine>("SelectPowerSubstationLineByFlagType", psl);

            sb = new Label[lli.Count];
            se = new TextEdit[lli.Count];
            j  = 0;
            foreach (PowerSubstationLine pss in lli)
            {
                sb[j]          = new Label();
                sb[j].Name     = "Label" + pss.Title;
                sb[j].Text     = pss.Title + ":";
                sb[j].Location = new Point(52, 27 + 33 * i);
                groupBox1.Controls.Add(sb[j]);

                se[j]          = new TextEdit();
                se[j].Name     = "Text" + pss.Title;
                se[j].Tag      = "Text" + pss.ClassType;
                se[j].Location = new Point(157, 26 + 33 * i);
                se[j].Size     = new Size(231, 21);
                groupBox1.Controls.Add(se[j]);
                try
                {
                    int num = 0;
                    if (se[j].Tag.ToString().Length <= 6)
                    {
                        num = int.Parse(se[j].Tag.ToString().Substring(se[j].Tag.ToString().Length - 1, 1)) - 1;
                    }
                    else
                    {
                        num = int.Parse(se[j].Tag.ToString().Substring(se[j].Tag.ToString().Length - 2, 2)) - 1;
                    }

                    if (ac1[num].ToString() != DBNull.Value.ToString() && ac1[num].ToString() != "")
                    {
                        se[j].Text = ac1[num].ToString();
                    }
                    else
                    {
                        se[j].Text = "";
                    }
                }
                catch (Exception ex)
                {
                    MsgBox.Show(ex.Message);
                }
                j++;
                i++;
            }



            try
            {
                tt1.Text = q3.ToString();
                tt2.Text = q1.ToString();
                tt3.Text = q0.ToString();
                tt4.Text = q2.ToString();
                tt6.Text = q4.ToString();
            }
            catch { }


            groupBox1.Size         = new Size(434, 30 + 33 * i);
            simpleButton1.Location = new Point(296, 50 + 33 * i);
            simpleButton2.Location = new Point(389, 50 + 33 * i);
            this.Size = new Size(490, 130 + 33 * i);
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: github188/myitoppsp
        private void InsertLineData1()
        {
            PowerTypes m2 = new PowerTypes();

            PowerValues m1 = new PowerValues();

            PowerYears z1 = new PowerYears();

            PowerTypes psp_Type = new PowerTypes();
            object     obj      = Services.BaseService.GetObject("SelectPowerTypesList", "");
            int        z_typeID = (int)Common.Services.BaseService.Create("InsertPowerTypes", psp_Type) - 2;


            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++)
                    {
                        foreach (DataColumn dc in dts.Columns)
                        {
                            if (dc.Caption.IndexOf("年") > 0)
                            {
                                try
                                {
                                    if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                    {
                                        m1.Value = 0;
                                    }
                                    else
                                    {
                                        m1.Value = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                    }
                                    m1.TypeID = z_typeID + 3;



                                    int    eq = dc.ColumnName.IndexOf("年");
                                    string h  = dc.ColumnName.Substring(0, eq);
                                    m1.Year = int.Parse(h);
                                    Services.BaseService.Create <PowerValues>(m1);
                                }
                                catch { }
                            }
                            if (dc.Caption.IndexOf("项目名称") >= 0)
                            {
                                try
                                {
                                    m2.Title = dts.Rows[i][dc.ColumnName].ToString();
                                }
                                catch { }
                            }

                            if (dc.Caption.IndexOf("静态总投资") >= 0)
                            {
                                try
                                {
                                    if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                    {
                                        m2.Jingtai = 0;
                                    }
                                    else
                                    {
                                        m2.Jingtai = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                    }
                                }
                                catch { }
                            }
                            if (dc.Caption.IndexOf("建设期间代款利息") >= 0)
                            {
                                try
                                {
                                    if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                    {
                                        m2.Lixi = 0;
                                    }
                                    else
                                    {
                                        m2.Lixi = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                    }
                                }
                                catch { }
                            }
                            if (dc.Caption.IndexOf("价格预备费") >= 0)
                            {
                                try
                                {
                                    if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                    {
                                        m2.Yubei = 0;
                                    }
                                    else
                                    {
                                        m2.Yubei = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                    }
                                }
                                catch { }
                            }
                            if (dc.Caption.IndexOf("动态投资") >= 0)
                            {
                                try
                                {
                                    if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                    {
                                        m2.Dongtai = 0;
                                    }
                                    else
                                    {
                                        m2.Dongtai = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                    }
                                }
                                catch { }
                            }
                        }
                        m2.Flag2 = this.ctrlPowerEachList1.FocusedObject.UID;
                        z_typeID = z_typeID + 1;
                        Services.BaseService.Create <PowerValues>(m1);
                        Services.BaseService.Create <PowerTypes>(m2);
                    }

                    ReLaodData();
                }
            }

            catch { MsgBox.Show("导入格式不正确!"); }
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: github188/myitoppsp
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }



            //if(treeList1.FocusedNode.ParentNode == null)
            //{
            //    MsgBox.Show("一级分类为固定内容,不能删除!");
            //    return;
            //}

            if (treeList1.FocusedNode.HasChildren)
            {
                MsgBox.Show("此项目下有子项目,请先删除子项目!");
                return;
            }

            if (MsgBox.ShowYesNo("是否删除项目 " + treeList1.FocusedNode.GetValue("Title") + "?") == DialogResult.Yes)
            {
                PowerTypes psp_Type = new PowerTypes();
                Class1.TreeNodeToDataObject <PowerTypes>(psp_Type, treeList1.FocusedNode);
                PowerValues PowerValues = new PowerValues();
                PowerValues.TypeID = psp_Type.ID;

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

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

                    TreeListNode brotherNode = null;
                    try
                    {
                        if (treeList1.FocusedNode.ParentNode.Nodes.Count > 1)
                        {
                            brotherNode = treeList1.FocusedNode.PrevNode;
                            if (brotherNode == null)
                            {
                                brotherNode = treeList1.FocusedNode.NextNode;
                            }
                        }
                    }
                    catch { }
                    treeList1.DeleteNode(treeList1.FocusedNode);

                    //删除后,如果同级还有其它分类,则重新计算此类的所有年份数据

                    if (brotherNode != null)
                    {
                        foreach (TreeListColumn column in treeList1.Columns)
                        {
                            if (column.FieldName.IndexOf("年") > 0)
                            {
                                CalculateSum(brotherNode, column);
                            }
                        }
                    }
                }
                catch //(Exception ex)
                {
                    //MsgBox.Show("删除出错:" + ex.Message);
                }
            }
        }