Example #1
0
        protected void butSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(EditKey.Text))
            {
                try
                {
                    EnumInfoModel model = new EnumInfoModel();
                    model.enumName = txtName.Text;
                    model.enumDescription = txtDescription.Text;
                    model.enumValueInfo = txtValueInfo.Text;
                    model.SlnID = SlnID;
                    if (DbDataLoader.Add(model) > 0)
                    {
                        Bind();
                        btCancelButton_Click(null, null);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败!')</script>");
                }
            }
            else
            {
                try
                {

                    EnumInfoModel model = new EnumInfoModel();
                    model.enumName = txtName.Text;
                    model.enumDescription = txtDescription.Text;
                    model.enumValueInfo = txtValueInfo.Text;
                    model.SlnID = SlnID;
                    model.ID = int.Parse(EditKey.Text);
                    if (DbDataLoader.Update(model))
                    {
                        Bind();
                        btCancelButton_Click(null, null);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Page.RegisterStartupScript("", "<script language=javascript>alert('编辑失败!')</script>");
                }
            }
        }
Example #2
0
 public static bool Update(EnumInfoModel model)
 {
     var command = _dbBaseProvider.CreateCommandStruct("EnumInfo", CommandMode.Modify);
     command.AddParameter("enumName", model.enumName);
     command.AddParameter("enumDescription", model.enumDescription);
     command.AddParameter("enumValueInfo", model.enumValueInfo);
     command.Filter = _dbBaseProvider.CreateCommandFilter();
     command.Filter.Condition = _dbBaseProvider.FormatFilterParam("ID");
     command.Filter.AddParam("ID", model.ID);
     command.Parser();
     return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0;
 }
Example #3
0
 public static bool Delete(EnumInfoModel model)
 {
     var command = _dbBaseProvider.CreateCommandStruct("EnumInfo", CommandMode.Delete);
     command.Filter = _dbBaseProvider.CreateCommandFilter();
     command.Filter.Condition = _dbBaseProvider.FormatFilterParam("ID");
     command.Filter.AddParam("ID", model.ID);
     command.Parser();
     return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0;
 }
Example #4
0
        public static List<EnumInfoModel> GetEnumInfo(Action<CommandFilter> match)
        {
            var command = _dbBaseProvider.CreateCommandStruct("EnumInfo", CommandMode.Inquiry);
            command.Columns = "Id,SlnID,enumName,enumDescription,enumValueInfo";
            command.OrderBy = "enumName ASC,Id ASC";
            command.Filter = _dbBaseProvider.CreateCommandFilter();
            if (match != null)
            {
                match(command.Filter);
            }
            command.Parser();
            var list = new List<EnumInfoModel>();
            using (var reader = _dbBaseProvider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters))
            {
                while (reader.Read())
                {
                    EnumInfoModel model = new EnumInfoModel();
                    model.ID = reader["ID"].ToInt();
                    model.SlnID = reader["SlnID"].ToInt();
                    model.enumName = reader["enumName"].ToNotNullString();
                    model.enumDescription = reader["enumDescription"].ToNotNullString();
                    model.enumValueInfo = reader["enumValueInfo"].ToNotNullString();

                    list.Add(model);
                }
            }
            return list;
        }
Example #5
0
 public static int Add(EnumInfoModel model)
 {
     var command = _dbBaseProvider.CreateCommandStruct("EnumInfo", CommandMode.Insert);
     command.AddParameter("SlnID", model.SlnID);
     command.AddParameter("enumName", model.enumName);
     command.AddParameter("enumDescription", model.enumDescription);
     command.AddParameter("enumValueInfo", model.enumValueInfo);
     command.Parser();
     return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters);
 }