public static int Add(VersionMode model) { var command = _dbBaseProvider.CreateCommandStruct("ContractVersion", CommandMode.Insert); command.AddParameter("SlnID", model.SlnID); command.AddParameter("Title", model.Title); command.ReturnIdentity = true; command.Parser(); return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters); }
protected void butSubmit_Click(object sender, EventArgs e) { try { VersionMode model = new VersionMode(); model.Title = Title.Text.Trim(); model.SlnID = Convert.ToInt32(Request.QueryString["gameid"]); if (DbDataLoader.Add(model) > 0) { Page.RegisterStartupScript("", "<script language=javascript>alert('添加成功!')</script>"); } } catch(Exception ex) { TraceLog.WriteError("AgreementAdd:{0}", ex); Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败,填写重复!')</script>"); } }
protected void butSubmit_Click(object sender, EventArgs e) { try { VersionMode model = new VersionMode(); model.Title = txtTitle.Text.Trim(); model.SlnID = SlnId; if (DbDataLoader.Add(model) > 0) { BindData(); Page.RegisterStartupScript("", "<script language=javascript>alert('添加成功!')</script>"); } } catch (Exception ex) { TraceLog.WriteError("AgreementAdd:{0}", ex); Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败,填写重复!')</script>"); } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { int id = Convert.ToInt32((string)GridView1.DataKeys[e.RowIndex].Values[0].ToString()); string title = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("itTitle")).Text; VersionMode model = new VersionMode(); model.ID = id; model.Title = title; model.SlnID = SlnId; if (DbDataLoader.Update(model)) { GridView1.EditIndex = -1; BindData(); } } catch (Exception erro) { Response.Write("错误信息:" + erro.Message); } }
public static List<VersionMode> GetVersion(int gameId) { var command = _dbBaseProvider.CreateCommandStruct("ContractVersion", CommandMode.Inquiry); command.Columns = "ID,SlnID,Title"; command.OrderBy = "SlnID ASC,ID ASC"; command.Filter = _dbBaseProvider.CreateCommandFilter(); command.Filter.Condition = _dbBaseProvider.FormatFilterParam("SlnID"); command.Filter.AddParam("SlnID", gameId); command.Parser(); var list = new List<VersionMode>(); using (var reader = _dbBaseProvider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters)) { while (reader.Read()) { VersionMode model = new VersionMode(); model.ID = reader["ID"].ToInt(); model.SlnID = reader["SlnID"].ToInt(); model.Title = reader["Title"].ToNotNullString(); list.Add(model); } } return list; }
public static bool Delete(VersionMode model) { var command = _dbBaseProvider.CreateCommandStruct("ContractVersion", 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; }
public static bool Update(VersionMode model) { var command = _dbBaseProvider.CreateCommandStruct("ContractVersion", CommandMode.Modify); if (model.SlnID > 0) { command.AddParameter("SlnID", model.SlnID); } command.AddParameter("Title", model.Title); 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; }