public void Save(BasicDictionary objBasicDictionary)
        {
            string sql = null;
            List<DbParameter> parameterList = new List<DbParameter>();

            if (objBasicDictionary.PkId == 0)
            {
                sql = " insert into tbl_basic_dictionary(DictKind, DictKey, DictValue, IsSystem) " +
                      " values(@DictKind, @DictKey, @DictValue, @IsSystem) ";

                parameterList.Add(new MySqlParameter("@DictKind", objBasicDictionary.DictKind));
                parameterList.Add(new MySqlParameter("@DictKey", objBasicDictionary.DictKey));
                parameterList.Add(new MySqlParameter("@DictValue", objBasicDictionary.DictValue));
                parameterList.Add(new MySqlParameter("@IsSystem", objBasicDictionary.IsSystem));
            }

            else
            {
                sql = " update tbl_basic_dictionary set DictValue=@DictValue where PkId=@PkId ";

                parameterList.Add(new MySqlParameter("@PkId", objBasicDictionary.PkId));
                parameterList.Add(new MySqlParameter("@DictValue", objBasicDictionary.DictValue));
            }

            DbHelper.ExecuteNonQuery(sql, CommandType.Text, parameterList.ToArray());
        }
        public void Save(BasicDictionary objBasicDictionary)
        {
            string sql = null;
            List<DbParameter> parameterList = new List<DbParameter>();

            if (objBasicDictionary.PkId == 0)
            {
                sql = " insert into tbl_basic_dictionary(PkId, DictKind, DictKey, DictValue, IsSystem) " +
                      " values(TBD_PKID.NEXTVAL, :DictKind, :DictKey, :DictValue, :IsSystem) ";

                parameterList.Add(new OracleParameter(":DictKind", objBasicDictionary.DictKind));
                parameterList.Add(new OracleParameter(":DictKey", objBasicDictionary.DictKey));
                parameterList.Add(new OracleParameter(":DictValue", objBasicDictionary.DictValue));
                parameterList.Add(new OracleParameter(":IsSystem", objBasicDictionary.IsSystem));
            }

            else
            {
                sql = " update tbl_basic_dictionary set DictValue=:DictValue where PkId=:PkId ";

                parameterList.Add(new OracleParameter(":DictValue", objBasicDictionary.DictValue));
                parameterList.Add(new OracleParameter(":PkId", objBasicDictionary.PkId));
            }

            DbHelper.ExecuteNonQuery(sql, CommandType.Text, parameterList.ToArray());
        }
        public bool CheckExists(BasicDictionary objBasicDictionary)
        {
            string sql = null;
            List<DbParameter> parameterList = new List<DbParameter>();

            sql = " select count(*) from tbl_basic_dictionary where DictKind=@DictKind and DictKey=@DictKey ";

            parameterList.Add(new MySqlParameter("@DictKind", objBasicDictionary.DictKind));
            parameterList.Add(new MySqlParameter("@DictKey", objBasicDictionary.DictKey));

            return int.Parse(DbHelper.ExecuteScalar(sql, CommandType.Text, parameterList.ToArray()).ToString()) > 0;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                IBasicService service = ServiceFactory.GetService<IBasicService>();

                BasicDictionary entity = null;

                if (this.IsInsert)
                {
                    entity = new BasicDictionary()
                    {
                        DictKind = this.Kind.ToByte(0),
                        DictKey = this.txtDictKey.Text.Trim().ToByte(0),
                        DictValue = this.txtDictValue.Text.Trim(),
                        IsSystem = 0
                    };

                    if (service.CheckExists_Dictionary(entity))
                    {
                        this.JscriptMsg("字典数据键已存在", null, "Error");

                        return;
                    }
                }

                else
                {
                    entity = service.GetObject_Dictionary(this.PkId);

                    if (entity != null)
                    {
                        entity.DictValue = this.txtDictValue.Text.Trim();
                    }
                }

                service.Save_Dictionary(entity);

                if (this.IsInsert && (sender as Button).CommandName == "SubmitContinue")
                {
                    this.ReturnUrl = this.Request.Url.PathAndQuery;
                }

                this.JscriptMsg("数据保存成功", this.ReturnUrl, "Success");
            }

            BasicConvert.ClearCache();
        }
Example #5
0
        public void Save_Dictionary(BasicDictionary objBasicDictionary)
        {
            var repository = ServiceFactory.GetService<IBasicDictionaryRepository>();

            repository.Save(objBasicDictionary);
        }
Example #6
0
        public bool CheckExists_Dictionary(BasicDictionary objBasicDictionary)
        {
            var repository = ServiceFactory.GetService<IBasicDictionaryRepository>();

            return repository.CheckExists(objBasicDictionary);
        }