コード例 #1
0
ファイル: FormModel.cs プロジェクト: ewgeny911/FBA
        private void dgvTable_DoubleClick(object sender, EventArgs e)
        {
            string objID     = dgvTable.Value("ID");
            string tableName = dgvTable.Value("Name");
            var    f1        = new FormTable(Operation.Edit, CompEntityTreeFBA1.EntityID, objID, tableName);

            f1.Icon = this.Icon;
            if (f1.ShowDialog() == DialogResult.OK)
            {
                LoadAttrList(CompEntityTreeFBA1.EntityID);
            }
        }
コード例 #2
0
ファイル: FormModel.cs プロジェクト: ewgeny911/FBA
        /// <summary>
        /// Контекстное меню.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddClick(object sender, EventArgs e)
        {
            Operation operation = Operation.NotAssigned;

            if (sender == cmModel_N1)
            {
                operation = Operation.Add;
            }
            if (sender == cmModel_N2)
            {
                operation = Operation.Edit;
            }
            if (sender == cmModel_N3)
            {
                operation = Operation.Del;
            }
            if (sender == cmModel_N4)
            {
                operation = Operation.Refresh;
            }
            //Обновить таблицы парсера.
            if (sender == cmModel_N5)
            {
                sys.CreateParserLocalTables();
                return;
            }

            if (operation == Operation.NotAssigned)
            {
                return;
            }

            //Компонент на котором повешено контекстное меню.
            string componentStrip = sys.GetControlNameByMenuStripItem(sender);
            string objID;
            string entityID    = CompEntityTreeFBA1.EntityID;
            string entityBrief = sys.GetEntityBrief(entityID);

            if (operation == Operation.Refresh)
            {
                if (componentStrip == "dgvAttr")
                {
                    LoadAttrList(CompEntityTreeFBA1.EntityID);
                }
                if (componentStrip == "dgvTable")
                {
                    LoadTableList(CompEntityTreeFBA1.EntityID);
                }
                if (componentStrip == "dgvMethod")
                {
                    LoadMethodList(CompEntityTreeFBA1.EntityID);
                }
                return;
            }

            //Атрибут.
            if (componentStrip == "dgvAttr")
            {
                objID = dgvAttr.Value("ID");
                string AttrBrief = dgvAttr.Value("Brief");
                string AttrName  = dgvAttr.Value("Name");
                if (sender == cmModel_N4)
                {
                    LoadAttrList(entityID);
                }
                var f1 = new FormAttr(operation, entityID, objID, AttrBrief, AttrName);
                f1.Icon = this.Icon;
                if (f1.ShowDialog() == DialogResult.OK)
                {
                    LoadAttrList(entityID);
                }
            }

            //Таблица.
            if (componentStrip == "dgvTable")
            {
                objID = dgvTable.Value("ID");
                string objName = dgvTable.Value("Name");
                if (sender == cmModel_N4)
                {
                    LoadTableList(entityID);
                }
                var f1 = new FormTable(operation, objID, objName, entityID);
                f1.Icon = this.Icon;
                if (f1.ShowDialog() == DialogResult.OK)
                {
                    LoadTableList(entityID);
                }
            }

            //Метод.
            if (componentStrip == "dgvMethod")
            {
                string methodID    = dgvMethod.Value("ID");
                string action      = dgvMethod.Value("Action");
                string methodBrief = dgvMethod.Value("Brief");
                string methodValue = dgvMethod.Value("Value");
                string comment     = dgvMethod.Value("Comment");
                string sql         = "";
                if (operation == Operation.Del)
                {
                    if (methodID == "")
                    {
                        return;
                    }
                    sql = "DELETE FROM fbaMethod WHERE ID = " + methodID;
                    if (!sys.Exec(DirectionQuery.Remote, sql))
                    {
                        return;
                    }
                    LoadMethodList(entityID);
                    sys.SM("Метод удален!", MessageType.Information);
                    return;
                }

                string capForm = "";
                if (operation == Operation.Add)
                {
                    capForm = "Add Entity Method";
                }
                if (operation == Operation.Edit)
                {
                    capForm = "Edit Entity Method";
                }
                if (operation == Operation.Del)
                {
                    capForm = "Delete Entity Method";
                }

                string[] actionArr = { "INSERT", "DELETE", "UPDATE" };

                /*var frm = new FormValue5(cap,
                 *                       "Entity", "Action", "Brief", "Value", "Comment",
                 *                       entityBrief, action, methodBrief, methodValue, comment,
                 *                       null, actionArr);
                 * frm.tbText1.ReadOnly = true;
                 * frm.tbText2.ReadOnly = true;
                 * if (frm.ShowDialog() != DialogResult.OK) return;
                 *
                 * entityBrief = frm.tbText1.Text;
                 * action      = frm.tbText2.Text;
                 * methodBrief = frm.tbText3.Text;
                 * methodValue = frm.tbText4.Text;
                 * comment     = frm.tbText5.Text;
                 */

                var arrvp = new ValueParam[5];
                arrvp[0].captionValue  = "Entity";
                arrvp[0].componentType = ComponentType.ComboBox;
                arrvp[0].values        = null;
                arrvp[0].value         = entityBrief;
                arrvp[0].readOnly      = true;

                arrvp[1].captionValue  = "Action";
                arrvp[1].componentType = ComponentType.ComboBox;
                arrvp[1].values        = actionArr;
                arrvp[1].value         = action;
                arrvp[1].readOnly      = true;

                arrvp[2].captionValue = "Brief";
                arrvp[2].value        = methodBrief;

                arrvp[3].captionValue = "Value";
                arrvp[3].value        = methodValue;

                arrvp[4].captionValue = "Comment";
                arrvp[4].value        = comment;

                var frm = new FormValue(capForm, arrvp);
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                entityBrief = frm.GetValue(0);
                action      = frm.GetValue(1);
                methodBrief = frm.GetValue(2);
                methodValue = frm.GetValue(3);
                comment     = frm.GetValue(4);


                if (operation == Operation.Add)
                {
                    sql = "INSERT INTO fbaMethod (" +
                          "UserCreateID, DateCreate, EntityRef, Action, Brief, Value, Comment) VALUES (" +
                          Var.UserID + ", " + sys.DateTimeCurrent() + "," + entityID + ",'" + action + "', '" + methodBrief + "', '" + methodValue + "', '" + comment + "')";
                    if (!sys.Exec(DirectionQuery.Remote, sql))
                    {
                        return;
                    }
                    sys.SM("Метод добавлен!", MessageType.Information);
                }
                if (operation == Operation.Edit)
                {
                    sql = "UPDATE fbaMethod SET " +
                          "UserChangeID = " + Var.UserID +
                          ",DateChange  = " + sys.DateTimeCurrent() +
                          ",EntityRef   = " + entityID +
                          ",Action      = '" + action + "'" +
                          ",Brief       = '" + methodBrief + "'" +
                          ",Value       = '" + methodValue + "'" +
                          ",Comment     = '" + comment + "'" +
                          " WHERE ID = " + methodID;
                    if (!sys.Exec(DirectionQuery.Remote, sql))
                    {
                        return;
                    }
                    sys.SM("Метод изменён!", MessageType.Information);
                }
                LoadMethodList(entityID);
            }
        }