private void BindAttType()
        {
            cbb_AttType.Items.Clear();
            LoadDataServices loadData = new LoadDataServices(pathInfo, countryCode);
            //militaryTypeList = loadData.LoadMilitaryType(localisationModel, countryCode);
            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.type == oobInfo.type);

            foreach (MilitaryTypeInfo m in militaryTypeList)
            {
                if (m.bigType == militaryTypeInfo.bigType)
                {
                    cbb_AttType.Items.Add(m.name);
                }
            }
            cbb_AttType.SelectedIndexChanged += new EventHandler(cbb_AttType_SelectedIndexChanged);
            cbb_AttType.SelectedItem          = militaryTypeInfo.name;
        }
        private void BindAttModel(string attTypeName)
        {
            cbb_AttModel.Items.Clear();
            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == attTypeName);

            if (militaryTypeInfo.unitModelList == null || militaryTypeInfo.unitModelList.Count == 0)
            {
                cbb_AttModel.Enabled = false;
            }
            else
            {
                cbb_AttModel.Enabled = true;
                foreach (UnitModelInfo u in militaryTypeInfo.unitModelList)
                {
                    cbb_AttModel.Items.Add(u.name);
                    if (u.modelNum == oobInfo.historical_model)
                    {
                        cbb_AttModel.SelectedItem = u.name;
                    }
                }
            }
        }
Beispiel #3
0
        private void Save(object sender, EventArgs e)
        {
            try
            {
                int ID = Convert.ToInt32(txt_BasicID.Text);

                OOBInfo oobUpdateInfo = oobList.Find(o => o.id == ID);
                //移除当前的oob
                //oobList.Remove(oobUpdateInfo);

                #region 赋值基本信息
                if (!string.IsNullOrEmpty(txt_BasicName.Text))
                {
                    oobUpdateInfo.name = txt_BasicName.Text;
                    this.tv_Military.SelectedNode.Text = txt_BasicName.Text;
                }
                if (!string.IsNullOrEmpty(txt_BasicLocation.Text))
                {
                    Regex           reg = new Regex(@"[0-9][0-9,.]*");
                    MatchCollection mc  = reg.Matches(txt_BasicLocation.Text);
                    if (mc.Count > 0)
                    {
                        if (oobUpdateInfo.armyType != ArmyTypeEnum.Navy && oobUpdateInfo.armyType != ArmyTypeEnum.Air)
                        {
                            oobUpdateInfo.location = mc[0].Value;
                        }
                        else
                        {
                            oobUpdateInfo.location = mc[0].Value;
                            oobUpdateInfo.baseID   = mc[0].Value;
                        }
                    }
                }
                if (cb_Reserve.Enabled && oobUpdateInfo.armyType == ArmyTypeEnum.Division)
                {
                    oobUpdateInfo.is_reserve = cb_Reserve.Checked;
                }
                if (!string.IsNullOrEmpty(txt_LeaderID.Text))
                {
                    oobUpdateInfo.leader = txt_LeaderID.Text.Trim();
                }
                //oobList.Add(oobUpdateInfo);
                #endregion

                #region 赋值附属部队的信息
                int currentAcNum = oobList.FindAll(att => att.parentID == ID &&
                                                   (att.armyType == ArmyTypeEnum.Regiment || att.armyType == ArmyTypeEnum.Ship || att.armyType == ArmyTypeEnum.Wing)).Count;
                int num = 0;
                foreach (Control c in this.panel1.Controls)
                {
                    if (num < currentAcNum)
                    {
                        AttachmentControl ac        = (AttachmentControl)c;
                        TextBox           txt_AttID = (TextBox)ac.Controls[0].Controls.Find("txt_AttID", false)[0];
                        int     attID            = Convert.ToInt32(txt_AttID.Text);
                        OOBInfo oobAttUpdateInfo = oobList.Find(o => o.id == attID);
                        //oobList.Remove(oobAttUpdateInfo);

                        TextBox txt_AttName = (TextBox)ac.Controls[0].Controls.Find("txt_AttName", false)[0];
                        if (!string.IsNullOrEmpty(txt_AttName.Text))
                        {
                            oobAttUpdateInfo.name = txt_AttName.Text;
                        }
                        TextBox txt_AttExp = (TextBox)ac.Controls[0].Controls.Find("txt_AttExp", false)[0];
                        if (!string.IsNullOrEmpty(txt_AttExp.Text))
                        {
                            oobAttUpdateInfo.experience = txt_AttExp.Text;
                        }
                        ComboBox cbb_AttType = (ComboBox)ac.Controls[0].Controls.Find("cbb_AttType", false)[0];
                        if (cbb_AttType.SelectedItem != null)
                        {
                            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                            oobAttUpdateInfo.type = militaryTypeInfo.type;
                        }
                        ComboBox cbb_AttModel = (ComboBox)ac.Controls[0].Controls.Find("cbb_AttModel", false)[0];
                        if (cbb_AttModel.SelectedItem != null)
                        {
                            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                            if (militaryTypeInfo.unitModelList != null || militaryTypeInfo.unitModelList.Count > 0)
                            {
                                oobAttUpdateInfo.historical_model = militaryTypeInfo.unitModelList.Find(uml => uml.name == cbb_AttModel.SelectedItem.ToString()).modelNum;
                            }
                        }
                        //oobList.Add(oobAttUpdateInfo);
                    }
                    else
                    {
                        Add_AttachmentControl aac = (Add_AttachmentControl)c;
                        TextBox txt_AttID         = (TextBox)aac.Controls[0].Controls.Find("txt_AttID", false)[0];
                        int     attID             = Convert.ToInt32(txt_AttID.Text);
                        OOBInfo oobAttAddInfo     = new OOBInfo();
                        oobAttAddInfo.id       = attID;
                        oobAttAddInfo.parentID = ID;
                        TextBox txt_AttName = (TextBox)aac.Controls[0].Controls.Find("txt_AttName", false)[0];
                        if (!string.IsNullOrEmpty(txt_AttName.Text))
                        {
                            oobAttAddInfo.name = txt_AttName.Text;
                        }
                        TextBox txt_AttExp = (TextBox)aac.Controls[0].Controls.Find("txt_AttExp", false)[0];
                        if (!string.IsNullOrEmpty(txt_AttExp.Text))
                        {
                            oobAttAddInfo.experience = txt_AttExp.Text;
                        }
                        ComboBox cbb_AttType = (ComboBox)aac.Controls[0].Controls.Find("cbb_AttType", false)[0];
                        if (cbb_AttType.SelectedItem != null)
                        {
                            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                            oobAttAddInfo.type = militaryTypeInfo.type;
                        }
                        ComboBox cbb_AttModel = (ComboBox)aac.Controls[0].Controls.Find("cbb_AttModel", false)[0];
                        if (cbb_AttModel.SelectedItem != null)
                        {
                            MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                            if (militaryTypeInfo.unitModelList != null || militaryTypeInfo.unitModelList.Count > 0)
                            {
                                oobAttAddInfo.historical_model = militaryTypeInfo.unitModelList.Find(uml => uml.name == cbb_AttModel.SelectedItem.ToString()).modelNum;
                            }
                        }
                        if (oobUpdateInfo.armyType == ArmyTypeEnum.Navy)
                        {
                            oobAttAddInfo.armyType = ArmyTypeEnum.Ship;
                        }
                        else if (oobUpdateInfo.armyType == ArmyTypeEnum.Air)
                        {
                            oobAttAddInfo.armyType = ArmyTypeEnum.Wing;
                        }
                        else
                        {
                            oobAttAddInfo.armyType = ArmyTypeEnum.Regiment;
                        }
                        oobList.Add(oobAttAddInfo);
                    }
                    num++;
                }
                #endregion

                //this.tv_Military.Nodes.Clear();
                BindTree(0, oobList);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("保存失败:" + ex.Message);
            }
        }
Beispiel #4
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                List <OOBInfo> oobList = new List <OOBInfo>();
                int            ID      = Convert.ToInt32(txt_BasicID.Text);

                OOBInfo oobAddInfo = new OOBInfo();

                #region 赋值基本信息
                oobAddInfo.id       = ID;
                oobAddInfo.parentID = parentID;
                if (!((string)cbb_BasicType.SelectedItem).Equals("请选择"))
                {
                    string attTypeName = (string)cbb_BasicType.SelectedItem;//获取当前选中项
                    oobAddInfo.armyType = ConvertArmyTypeStringToEnum(attTypeName);
                }
                if (!string.IsNullOrEmpty(txt_BasicName.Text))
                {
                    oobAddInfo.name = txt_BasicName.Text.Trim();
                }
                if (!string.IsNullOrEmpty(txt_BasicLocation.Text))
                {
                    Regex           reg = new Regex(@"[0-9][0-9,.]*");
                    MatchCollection mc  = reg.Matches(txt_BasicLocation.Text);
                    if (mc.Count > 0)
                    {
                        if (oobAddInfo.armyType != ArmyTypeEnum.Navy && oobAddInfo.armyType != ArmyTypeEnum.Air)
                        {
                            oobAddInfo.location = mc[0].Value;
                        }
                        else
                        {
                            oobAddInfo.location = mc[0].Value;
                            oobAddInfo.baseID   = mc[0].Value;
                        }
                    }
                }
                if (cb_Reserve.Enabled && oobAddInfo.armyType == ArmyTypeEnum.Division)
                {
                    oobAddInfo.is_reserve = cb_Reserve.Checked;
                }
                oobList.Add(oobAddInfo);
                #endregion

                #region 赋值附属部队的信息
                foreach (Control c in this.panel1.Controls)
                {
                    Add_AttachmentControl aac = (Add_AttachmentControl)c;
                    TextBox txt_AttID         = (TextBox)aac.Controls[0].Controls.Find("txt_AttID", false)[0];
                    int     attID             = Convert.ToInt32(txt_AttID.Text);
                    OOBInfo oobAttAddInfo     = new OOBInfo();
                    oobAttAddInfo.id       = attID;
                    oobAttAddInfo.parentID = ID;
                    TextBox txt_AttName = (TextBox)aac.Controls[0].Controls.Find("txt_AttName", false)[0];
                    if (!string.IsNullOrEmpty(txt_AttName.Text))
                    {
                        oobAttAddInfo.name = txt_AttName.Text;
                    }
                    TextBox txt_AttExp = (TextBox)aac.Controls[0].Controls.Find("txt_AttExp", false)[0];
                    if (!string.IsNullOrEmpty(txt_AttExp.Text))
                    {
                        oobAttAddInfo.experience = txt_AttExp.Text;
                    }
                    ComboBox cbb_AttType = (ComboBox)aac.Controls[0].Controls.Find("cbb_AttType", false)[0];
                    if (cbb_AttType.SelectedItem != null)
                    {
                        MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                        oobAttAddInfo.type = militaryTypeInfo.type;
                    }
                    ComboBox cbb_AttModel = (ComboBox)aac.Controls[0].Controls.Find("cbb_AttModel", false)[0];
                    if (cbb_AttModel.SelectedItem != null)
                    {
                        MilitaryTypeInfo militaryTypeInfo = militaryTypeList.Find(m => m.name == cbb_AttType.SelectedItem.ToString());
                        if (militaryTypeInfo.unitModelList != null || militaryTypeInfo.unitModelList.Count > 0)
                        {
                            oobAttAddInfo.historical_model = militaryTypeInfo.unitModelList.Find(uml => uml.name == cbb_AttModel.SelectedItem.ToString()).modelNum;
                        }
                    }
                    if (oobAddInfo.armyType == ArmyTypeEnum.Navy)
                    {
                        oobAttAddInfo.armyType = ArmyTypeEnum.Ship;
                    }
                    else if (oobAddInfo.armyType == ArmyTypeEnum.Air)
                    {
                        oobAttAddInfo.armyType = ArmyTypeEnum.Wing;
                    }
                    else
                    {
                        oobAttAddInfo.armyType = ArmyTypeEnum.Regiment;
                    }
                    oobList.Add(oobAttAddInfo);
                }
                #endregion

                this.Close();
                this.add_military(oobList);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("保存失败:" + ex.Message);
            }
        }