protected void butSubmit_Click(object sender, EventArgs e) { try { ContractModel model = new ContractModel(); model.ID = Convert.ToInt32((string) txtID.Text.Trim()); model.Descption = txtDescption.Text.Trim(); model.ParentID = 1; model.SlnID = SlnID; model.AgreementID = ddlAgreement.SelectedValue.ToInt(); if (DbDataLoader.Add(model) > 0) { Response.Redirect(String.Format("index.aspx?ID={0}&slnID={1}", model.ID, model.SlnID)); return; } } catch(Exception ex) { Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败,填写重复!')</script>"); } }
protected void btnDeldte_Click(object sender, EventArgs e) { if (!DropGetList.Text.Trim().Equals("")) { var contractModel = new ContractModel() { ID = DropGetList.Text.ToInt(), SlnID = ddlSolution.Text.ToInt() }; if (DbDataLoader.Delete(contractModel)) { Response.Write("<script language=javascript>alert('删除成功!')</script>"); QueryResult(); Bind(); } else { Response.Write("<script language=javascript>alert('删除失败!')</script>"); } } }
public static int Add(ContractModel model) { var command = _dbBaseProvider.CreateCommandStruct("Contract", CommandMode.Insert); command.AddParameter("ID", model.ID); command.AddParameter("Descption", model.Descption); command.AddParameter("ParentID", model.ParentID); command.AddParameter("SlnID", model.SlnID); command.AddParameter("Complated", model.Complated); command.AddParameter("AgreementID", model.AgreementID); command.Parser(); return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters); }
public static List<ContractModel> GetContract(Action<CommandFilter> match) { var command = _dbBaseProvider.CreateCommandStruct("Contract", CommandMode.Inquiry); command.Columns = "ID,Descption,ParentID,SlnID,Complated,AgreementID"; command.OrderBy = "SlnID ASC,ID ASC"; command.Filter = _dbBaseProvider.CreateCommandFilter(); if (match != null) { match(command.Filter); } command.Parser(); var list = new List<ContractModel>(); using (var reader = _dbBaseProvider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters)) { while (reader.Read()) { ContractModel model = new ContractModel(); model.ID = reader["ID"].ToInt(); model.Descption = reader["Descption"].ToNotNullString(); model.ParentID = reader["ParentID"].ToInt(); model.SlnID = reader["SlnID"].ToInt(); model.Complated = reader["Complated"].ToBool(); model.AgreementID = reader["AgreementID"].ToInt(); list.Add(model); } } return list; }
public static bool Update(ContractModel model) { var command = _dbBaseProvider.CreateCommandStruct("Contract", CommandMode.Modify); command.AddParameter("Descption", model.Descption); command.AddParameter("ParentID", model.ParentID); command.AddParameter("Complated", model.Complated); if (model.AgreementID > 0) { command.AddParameter("AgreementID", model.AgreementID); } command.Filter = _dbBaseProvider.CreateCommandFilter(); command.Filter.Condition = string.Format("{0} AND {1}", _dbBaseProvider.FormatFilterParam("ID"), _dbBaseProvider.FormatFilterParam("SlnID")); command.Filter.AddParam("ID", model.ID); command.Filter.AddParam("SlnID", model.SlnID); command.Parser(); return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0; }
public static bool Delete(ContractModel model) { if (Delete(new ParamInfoModel() { ContractID = model.ID, SlnID = model.SlnID })) { var command = _dbBaseProvider.CreateCommandStruct("Contract", CommandMode.Delete); command.Filter = _dbBaseProvider.CreateCommandFilter(); command.Filter.Condition = string.Format("{0} AND {1}", _dbBaseProvider.FormatFilterParam("ID"), _dbBaseProvider.FormatFilterParam("SlnID")); command.Filter.AddParam("ID", model.ID); command.Filter.AddParam("SlnID", model.SlnID); command.Parser(); return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0; } return false; }
public static bool CopyContract(int slnID, int contractID, int copySlnID, int copyContractID) { var contract = GetContract(slnID, contractID); if (contract == null) { return false; } var contractcopy = new ContractModel() { ID = copyContractID, SlnID = copySlnID, AgreementID = contract.AgreementID, Complated = false, Descption = contract.Descption, ParentID = contract.ParentID }; if (Add(contractcopy) > 0) { var paramList = GetParamInfo(slnID, contractID); foreach (var paramInfo in paramList) { var info = new ParamInfoModel() { ContractID = contractcopy.ID, SlnID = contractcopy.SlnID, CreateDate = MathUtils.Now, Creator = paramInfo.Creator, Descption = paramInfo.Descption, Field = paramInfo.Field, FieldType = paramInfo.FieldType, FieldValue = paramInfo.FieldValue, MinValue = paramInfo.MinValue, MaxValue = paramInfo.MaxValue, Remark = paramInfo.Remark, Required = paramInfo.Required, ParamType = paramInfo.ParamType, SortID = paramInfo.SortID }; Add(info); } return true; } return false; }
protected void butSubmit_Click(object sender, EventArgs e) { ContractModel model = new ContractModel(); model.ID = ContractID; model.SlnID = SlnID; model.Descption = txtDescption.Text.Trim(); model.AgreementID = Convert.ToInt32((string) ddlAgreement.SelectedValue); if (DbDataLoader.Update(model)) { Response.Write("<script language=javascript>alert('修改成功!')</script>"); } }
protected void btnDelete_Click(object sender, EventArgs e) { try { var contractModel = new ContractModel() { ID = txtID.Text.ToInt(), SlnID = SlnID }; if (DbDataLoader.Delete(contractModel)) { Response.Write("<script language=javascript>alert('删除成功!')</script>"); Response.Redirect("Default.aspx?edit=true"); } else { Response.Write("<script language=javascript>alert('删除失败!')</script>"); } } catch (Exception ex) { TraceLog.WriteError("delete contract error:{0}", ex); } }
protected void butSubmit_Click(object sender, EventArgs e) { try { ContractModel model = new ContractModel(); model.ID = Convert.ToInt32((string)txtID.Text.Trim()); model.Descption = txtDescption.Text.Trim(); model.ParentID = 1; model.SlnID = SlnID; model.VerID = Convert.ToInt32(ddVersion.Text.Trim()); model.AgreementID = ddlAgreement.SelectedValue.ToInt(); if (IsModify) { DbDataLoader.Update(model); } else { DbDataLoader.Add(model); } Response.Redirect(string.Format("Default.aspx?edit=true&ID={0}&slnID={1}&VerID={2}&GameID={1}&AgreementID={3}", model.ID, model.SlnID, model.VerID, model.AgreementID)); } catch (Exception ex) { Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败,填写重复!')</script>"); } }