コード例 #1
0
ファイル: DictForm.aspx.cs プロジェクト: xiyuansu/xiaobao
        protected void Save_Click(object sender, EventArgs e)
        {
            try
            {
                Hashtable ht = new Hashtable();

                bool addError = false;

                if (string.IsNullOrEmpty(_key))
                {
                    DataTable dt = dictManager.GetItem(this.drpDic.SelectedValue.ToString(), this.txtName.Text.Trim().ToString());

                    if (dt.Rows.Count > 0)
                    {
                        addError = true;
                        ShowMsgHelper.Alert_Error("此字典项目已经添加,请重新添加!");
                    }
                }

                // 条目名称
                ht["Name"] = this.txtName.Text.Trim();
                // 备注说明
                ht["Remark"]   = this.txtRemark.Text.Trim();
                ht["CityCode"] = this.txtCityCode.Text.Trim();
                ht["ZipCode"]  = this.txtZipCode.Text.Trim();

                ht["Longitude"] = this.txtLongitude.Text.Trim();
                ht["Latitude"]  = this.txtLatitude.Text.Trim();
                //排列顺序
                ht["Sort"] = string.IsNullOrEmpty(this.txtSort.Text.Trim()) ? "9999" : this.txtSort.Text.Trim();
                // 备注说明
                ht["DictID"] = this.drpDic.SelectedValue.ToString();
                // 状态(0未启用,1启用)
                if (radOK.Checked)
                {
                    ht["DeleteMark"] = "1";
                }
                else
                {
                    ht["DeleteMark"] = "0";
                }

                if (!string.IsNullOrEmpty(_key))
                {
                    ht["ID"] = _key;
                }
                else
                {
                    ht["ID"] = CommonHelper.GetGuid;
                }
                if (addError)
                {
                }
                else
                {
                    bool result = dictManager.AddOrEditMessageInfo(ht, _key);

                    if (result)
                    {
                        ShowMsgHelper.AlertMsgNoFresh("操作成功!");
                    }
                    else
                    {
                        ShowMsgHelper.Alert_Error("操作失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }