Ejemplo n.º 1
0
        void Delete()
        {
            var selRow = SelectdRow();

            if (null == selRow)
            {
                SharedLogic.ShowMessage("请选择要删除的行");
                return;
            }
            var selXml = SharedLogic.GetSkillXml(this._rootXml, selRow[SkillItemData.COLSkillCode].ToString());

            if (null == selXml)
            {
                SharedLogic.ShowMessage("未找到要删除的节点");
                return;
            }
            string skillCode = selRow[SkillItemData.COLSkillCode].ToString();

            if (MessageBox.Show("确定要删除技能[" + skillCode + "]吗?", "系统信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
            {
                return;
            }
            this._bindData.Rows.Remove(selRow);
            this._bindData.AcceptChanges();
            selXml.Remove();
        }
Ejemplo n.º 2
0
 void menuCheck_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(this._openFilePath))
     {
         SharedLogic.ShowMessage("请先打开需要验证的文件");
         return;
     }
     if (CheckRules.CheckFile(this._openFilePath))
     {
         SharedLogic.ShowMessage("文件格式正确有效");
     }
 }
Ejemplo n.º 3
0
        void Edit(OperationState opState)
        {
            string skillCode = string.Empty;

            if (opState == OperationState.Edit || opState == OperationState.CopyNew)
            {
                var selRow = SelectdRow();
                if (null == selRow)
                {
                    SharedLogic.ShowMessage("请选择要编辑的行");
                    return;
                }
                skillCode = selRow[SkillItemData.COLSkillCode].ToString();
            }
            this._bindData.TableName = string.Empty;
            var editForm = new SkillEditForm();

            editForm.Init(opState, skillCode, this._rootXml, this._bindData);
            editForm.ShowDialog();
            string newCode = this._bindData.TableName;

            if (string.IsNullOrEmpty(newCode))
            {
                return;
            }
            foreach (DataGridViewRow gridRow in this.gridList.Rows)
            {
                var bindRow = ((DataRowView)gridRow.DataBoundItem).Row;
                if (string.Compare(bindRow[SkillItemData.COLSkillCode].ToString(), newCode, true) == 0)
                {
                    gridRow.Selected     = true;
                    gridList.CurrentCell = gridRow.Cells[0];
                    return;
                }
            }
            this._bindData.DefaultView.RowFilter = "";
        }
Ejemplo n.º 4
0
 void Save(bool newFlag)
 {
     if (string.IsNullOrEmpty(this._openFilePath) || newFlag)
     {
         if (this._diagSaveFile.ShowDialog() != DialogResult.OK)
         {
             return;
         }
     }
     try
     {
         this._bindData.DefaultView.RowFilter = "";
         var nXml = SharedLogic.WrapSaveXml(this._rootXml);
         nXml.Save(this._openFilePath);
         var    clientXml = SharedLogic.GenClientXml(nXml);
         string fileName  = this._openFilePath.Substring(this._openFilePath.LastIndexOf('\\') + 1);
         clientXml.Save(this._openFilePath.Replace(fileName, "SkillClient.xml"));
         SharedLogic.ShowMessage("保存成功");
     }
     catch (Exception ex)
     {
         SharedLogic.ShowMessage("保存文件失败:" + ex.Message + "\n" + ex.StackTrace);
     }
 }
Ejemplo n.º 5
0
        void Save()
        {
            string skillCode = this.ucSkill.txtSkillCode.Text.Trim();
            string nSkillId  = this.ucSkill.txtSKillId.Text.Trim();

            if (string.IsNullOrEmpty(skillCode))
            {
                SharedLogic.ShowMessage("技能Code不可为空");
                return;
            }
            var rows = _bindData.Select(SkillItemData.COLSkillCode + "='" + skillCode + "'");

            if (skillCode != this._editCode && null != rows && rows.Length > 0)
            {
                SharedLogic.ShowMessage("该技能Code已存在");
                this.ucSkill.txtSkillCode.Focus();
                return;
            }
            rows = _bindData.Select(SkillItemData.COLSkillId + "='" + nSkillId.TrimStart('0') + "'");
            if (null != rows)
            {
                foreach (var dr in rows)
                {
                    if (dr[SkillItemData.COLSkillCode].ToString() != _editCode)
                    {
                        SharedLogic.ShowMessage("该技能Id已存在");
                        this.ucSkill.txtSKillId.Focus();
                        return;
                    }
                }
            }
            var nXml = this.ucSkill.GetValue();

            if (null == nXml)
            {
                SharedLogic.ShowMessage("构造XML失败");
                return;
            }
            this._editXml.RemoveAll();
            this._editXml.Add(nXml.Attributes());
            this._editXml.Add(nXml.Nodes());
            var obj = new SkillItemData();

            SharedLogic.TryGetBindSkillItem(nXml, obj);
            if (this.OpState != OperationState.Edit)
            {
                this._rootXml.Add(this._editXml);
                this._bindData.Rows.Add(obj.Values);
                if (this.OpState == OperationState.New)
                {
                    this.OpState   = OperationState.Edit;
                    this._editCode = skillCode;
                }
                else if (this.OpState == OperationState.Renew || this.OpState == OperationState.CopyNew)
                {
                    this._editXml = new XElement(SharedLogic.KEYSkill);
                    this.ucSkill.txtSkillCode.Text = "";
                    this.ucSkill.txtSkillCode.Focus();
                }
                this._bindData.TableName = skillCode;
            }
            else
            {
                var editRows = _bindData.Select(SkillItemData.COLSkillCode + "='" + this._editCode + "'");
                if (null == editRows || editRows.Length == 0)
                {
                    SharedLogic.ShowMessage("未找到编辑的行");
                    return;
                }
                editRows[0][SkillItemData.COLSkillId]      = obj.SkillId;
                editRows[0][SkillItemData.COLSkillName]    = obj.SkillName;
                editRows[0][SkillItemData.COLSkillSrcType] = obj.SkillType;
                editRows[0][SkillItemData.COLModelId]      = obj.ModelId;
                editRows[0][SkillItemData.COLOpenClipId]   = obj.OpenClipId;
                editRows[0][SkillItemData.COLClipId]       = obj.ClipId;
                editRows[0][SkillItemData.COLMemo]         = obj.Memo;
            }
            this._bindData.AcceptChanges();
            SharedLogic.ShowMessage("保存成功");
        }