Exemple #1
0
        private void LoadData()
        {
            switch (Mode)
            {
            case OperateMode.ADD:     // 新增
            {
                txtCode.Value = dictCode;
                break;
            }

            case OperateMode.UPDATE:     // 修改
            {
                DictItems itemModel = diBll.GetModel(itemID);

                if (itemModel == null)
                {
                    WebCommon.DialogAlertMsg(this, "不存在该字典!", "window.history.go(-1);");
                    return;
                }

                txtCode.Value      = itemModel.DictCode;
                txtItemCode.Value  = itemModel.ItemCode;
                UpdateItemCode     = itemModel.ItemCode;
                txtName.Value      = itemModel.ItemName;
                txtItemValue.Value = itemModel.ItemValue;
                txtRemark.Value    = itemModel.Remark;
                break;
            }
            }
        }
Exemple #2
0
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            DictItems itemModel = new DictItems();
            string    dictCode  = txtCode.Value.Trim();
            string    itemCode  = txtItemCode.Value.Trim();
            string    name      = txtName.Value.Trim();
            string    itemValue = txtItemValue.Value.Trim();
            string    remark    = txtRemark.Value.Trim();

            // 修改
            if (Mode == OperateMode.UPDATE)
            {
                // 如果存在重名,返回
                if (diBll.IsExists(item => item.ItemCode != UpdateItemCode && item.ItemCode == itemCode))
                {
                    WebCommon.DialogAlertMsg(this, "项编号已经存在,请重新输入!", string.Format("$('#{0}').focus();", txtItemCode.ClientID));
                    return;
                }

                itemModel                = diBll.GetModel(itemID);
                itemModel.ItemCode       = itemCode;
                itemModel.ItemName       = name;
                itemModel.ItemValue      = itemValue;
                itemModel.Remark         = remark;
                itemModel.LastUpdateDate = DateTime.Now;
                diBll.Update(itemModel);
            }
            else // 新增
            {
                if (string.IsNullOrEmpty(itemCode))
                {
                    WebCommon.DialogAlertMsg(this, "项编号不能为空,请重新输入!", string.Format("$('#{0}').focus();", txtItemCode.ClientID));
                    return;
                }

                if (diBll.IsExists(item => item.DictCode == dictCode && item.ItemCode == itemCode))
                {
                    WebCommon.DialogAlertMsg(this, "项编号已经存在,请重新输入!", string.Format("$('#{0}').focus();", txtItemCode.ClientID));
                    return;
                }

                itemModel.DictCode       = dictCode;
                itemModel.CreateDate     = DateTime.Now;
                itemModel.ItemCode       = itemCode;
                itemModel.ItemName       = name;
                itemModel.ItemValue      = itemValue;
                itemModel.Remark         = remark;
                itemModel.LastUpdateDate = DateTime.Now;
                diBll.Add(itemModel);
                WebCommon.ResetControl(this.form1);
            }

            WebCommon.DialogSuccessMsg(this, "保存成功!");
        }
Exemple #3
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="model">实体</param>
 public void Delete(DictItems model)
 {
     dal.Delete <DictItems>(model);
 }
Exemple #4
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="model">实体</param>
 public void Update(DictItems model)
 {
     dal.Update <DictItems>(model);
 }
Exemple #5
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="model">实体</param>
 /// <returns>主键值</returns>
 public object Add(DictItems model)
 {
     return(dal.Add <DictItems>(model));
 }
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();
        languageDictSO.Update();

        langName = EditorGUILayout.TextField("Language Name", langName);

        if (GUILayout.Button("Add Language"))
        {
            LanguageStuff newLang = new LanguageStuff();
            newLang.Language = langName;
            languageDict.Languages.Add(newLang);
        }

        if (cnt.intValue == 0)
        {
            EditorGUILayout.LabelField("No Current Languages");
        }
        else
        {
            for (int i = 0; i < cnt.intValue; i++)
            {
                if (languageDict.Languages[i] != null)
                {
                    EditorGUILayout.LabelField(languageDict.Languages[i].Language);
                    EditorGUILayout.LabelField("Key and Values");
                    for (int k = 0; k < languageDict.Languages[i].keyAndValue.Count; k++)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField(languageDict.Languages[i].keyAndValue[k].key);
                        languageDict.Languages[i].keyAndValue[k].value = EditorGUILayout.TextField(languageDict.Languages[i].keyAndValue[k].value);
                        if (GUILayout.Button("Del"))
                        {
                            List <DictItems> copyKey = new List <DictItems>();
                            // languageDict.language
                            for (int j = 0; j < languageDict.Languages[i].keyAndValue.Count; j++)
                            {
                                //languageDict.Languages[j] = languageDict.Languages[j + 1];
                                if (j != k)
                                {
                                    copyKey.Add(languageDict.Languages[i].keyAndValue[j]);
                                }
                            }
                            languageDict.Languages[i].keyAndValue = copyKey;
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    newKey = EditorGUILayout.TextField("Key", newKey);
                    newVal = EditorGUILayout.TextField("Value", newVal);
                    if (GUILayout.Button("Add Key and Value"))
                    {
                        DictItems newDict = new DictItems();
                        newDict.key   = newKey;
                        newDict.value = newVal;
                        languageDict.Languages[i].keyAndValue.Add(newDict);
                    }

                    if (GUILayout.Button("Delete Language"))
                    {
                        List <LanguageStuff> copy = new List <LanguageStuff>();
                        // languageDict.language
                        for (int j = 0; j < languageDict.Languages.Count; j++)
                        {
                            //languageDict.Languages[j] = languageDict.Languages[j + 1];
                            if (j != i)
                            {
                                copy.Add(languageDict.Languages[j]);
                            }
                        }
                        languageDict.Languages = copy;
                    }
                }
            }
        }


        languageDictSO.ApplyModifiedProperties();
    }