示例#1
0
 public static int Add(AgreementModel model)
 {
     var command = _dbBaseProvider.CreateCommandStruct("AgreementClass", CommandMode.Insert);
     command.AddParameter("GameID", model.GameID);
     command.AddParameter("Title", model.Title);
     command.AddParameter("Describe", model.Describe);
     command.ReturnIdentity = true;
     command.Parser();
     using (var reader = _dbBaseProvider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters))
     {
         if (reader.Read())
         {
             model.AgreementID = reader[0].ToInt();
         }
     }
     return model.AgreementID;
 }
示例#2
0
        protected void butSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                AgreementModel model = new AgreementModel();
                model.Title = Title.Text.Trim();
                model.Describe = Describe.Text.Trim();
                model.GameID = Convert.ToInt32(Request.QueryString["gameid"]);
                if (DbDataLoader.Add(model) > 0)
                {
                    Page.RegisterStartupScript("", "<script language=javascript>alert('添加成功!')</script>");
                }

            }
            catch(Exception ex)
            {
                Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败,填写重复!')</script>");
            }
        }
示例#3
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
                string Title = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Title")).Text;
                string Describe = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Describe")).Text;


                AgreementModel mode = new AgreementModel();
                mode.AgreementID = id;
                mode.Title = Title;
                mode.Describe = Describe;

                if (DbDataLoader.Update(mode))
                {
                    GridView1.EditIndex = -1;
                    BindData();
                }
            }

            catch (Exception erro)
            {
                Response.Write("错误信息:" + erro.Message);
            }
        }
示例#4
0
 public static bool Update(AgreementModel model)
 {
     var command = _dbBaseProvider.CreateCommandStruct("AgreementClass", CommandMode.Modify);
     command.AddParameter("Title", model.Title);
     command.AddParameter("Describe", model.Describe);
     command.Filter = _dbBaseProvider.CreateCommandFilter();
     command.Filter.Condition = _dbBaseProvider.FormatFilterParam("AgreementID");
     command.Filter.AddParam("AgreementID", model.AgreementID);
     command.Parser();
     return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0;
 }
示例#5
0
        public static List<AgreementModel> GetAgreement(Action<CommandFilter> match)
        {
            var command = _dbBaseProvider.CreateCommandStruct("AgreementClass", CommandMode.Inquiry);
            command.Columns = string.Format("AgreementID,GameID,Title,Describe,CreateDate,(SELECT SLNNAME FROM SOLUTIONS WHERE SLNID={0}.GAMEID) SlnName", command.TableName);
            command.OrderBy = "AgreementID ASC";
            command.Filter = _dbBaseProvider.CreateCommandFilter();
            if (match != null)
            {
                match(command.Filter);
            }
            command.Parser();
            var list = new List<AgreementModel>();
            using (var reader = _dbBaseProvider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters))
            {
                while (reader.Read())
                {
                    AgreementModel model = new AgreementModel();
                    model.AgreementID = reader["AgreementID"].ToInt();
                    model.GameID = reader["GameID"].ToInt();
                    model.Title = reader["Title"].ToNotNullString();
                    model.Describe = reader["Describe"].ToNotNullString();
                    model.CreateDate = reader["CreateDate"].ToDateTime();
                    model.SlnName = reader["SlnName"].ToNotNullString();

                    list.Add(model);
                }
            }
            return list;
        }