public static int Add(ParamInfoModel model) { var command = _dbBaseProvider.CreateCommandStruct("ParamInfo", CommandMode.Insert); command.ReturnIdentity = true; command.AddParameter("SlnID", model.SlnID); command.AddParameter("ContractID", model.ContractID); command.AddParameter("ParamType", model.ParamType); command.AddParameter("Field", model.Field); command.AddParameter("FieldType", model.FieldType); command.AddParameter("Descption", model.Descption); command.AddParameter("FieldValue", model.FieldValue); command.AddParameter("Required", model.Required); command.AddParameter("Remark", model.Remark); command.AddParameter("SortID", model.SortID); command.AddParameter("Creator", model.Creator); command.AddParameter("CreateDate", model.CreateDate); command.AddParameter("Modifier", model.Modifier); if (model.CreateDate == DateTime.MinValue) { model.CreateDate = MathUtils.Now; } if (model.ModifyDate == DateTime.MinValue) { model.ModifyDate = MathUtils.SqlMinDate; } command.AddParameter("ModifyDate", model.ModifyDate); command.AddParameter("MinValue", model.MinValue); command.AddParameter("MaxValue", model.MaxValue); command.Parser(); return(_dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters)); }
protected void gvGetlist_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { TableCell cell = gvGetlist.Rows[e.RowIndex].Cells[0]; ParamInfoModel mode = new ParamInfoModel(); mode.ID = Convert.ToInt32(((Label)cell.FindControl("IDLabel")).Text.ToString().Trim()); mode.ContractID = Convert.ToInt32((string)DropGetList.Text); mode.ParamType = Convert.ToInt32(((DropDownList)cell.FindControl("droParamType")).SelectedValue); mode.Field = ((TextBox)cell.FindControl("txtField")).Text.ToString().Trim(); mode.FieldType = ((DropDownList)cell.FindControl("droFieldType")).SelectedValue.ToEnum <FieldType>(); mode.Descption = ((TextBox)cell.FindControl("txtDescption")).Text.ToString().Trim(); mode.Required = Convert.ToBoolean(((DropDownList)cell.FindControl("droRequired")).SelectedValue); mode.Remark = ((TextBox)cell.FindControl("txtRemark")).Text.ToString().Trim(); mode.SortID = Convert.ToInt32(((TextBox)cell.FindControl("txtSortID")).Text.ToString().Trim()); mode.FieldValue = ((TextBox)cell.FindControl("txtFieldValue")).Text.ToString().Trim(); mode.MinValue = Convert.ToInt32(((TextBox)cell.FindControl("txtMinValue")).Text.ToString().Trim()); mode.MaxValue = Convert.ToInt32(((TextBox)cell.FindControl("txtMaxValue")).Text.ToString().Trim()); mode.ModifyDate = MathUtils.Now; if (DbDataLoader.Update(mode)) { gvGetlist.EditIndex = -1; QueryResult(); } } catch (Exception erro) { TraceLog.WriteError("RowUpdating:{0}", erro); Response.Write("错误信息:" + erro.Message); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ParamInfoModel model) { FieldType fieldType = (FieldType)Enum.ToObject(typeof(FieldType), model.FieldType); if (FieldType.Record == fieldType || fieldType == FieldType.End || fieldType == FieldType.Head) { model.Field = string.Empty; } return(dal.Update(model)); }
protected void btnParamAdd_Click(object sender, EventArgs e) { try { ParamInfoModel mode = new ParamInfoModel(); mode.Field = txtField.Text.Trim(); mode.FieldValue = ""; mode.Remark = txtRemark.Text.Trim(); mode.ContractID = ddContract.Text.ToInt(); mode.FieldType = ddFieldType.Text.ToEnum <FieldType>(); mode.ParamType = ddParamType.Text.ToInt(); mode.Required = ckRequired.Checked; mode.Descption = ""; mode.SlnID = ddlSolution.Text.ToInt(); mode.MinValue = 0; mode.MaxValue = 0; mode.CreateDate = DateTime.Now; mode.VerID = ddVersion.Text.ToInt(); var paramList = DbDataLoader.GetParamInfo(mode.SlnID, mode.ContractID, mode.ParamType, mode.VerID); int sortID = 0; if (!string.IsNullOrEmpty(ddResponseParams.Text)) { sortID = ddResponseParams.Text.ToInt() + 1; } else { sortID = paramList.Count == 0 ? 1 : paramList.Max(t => t.SortID) + 1; } mode.SortID = sortID; foreach (var param in paramList) { if (param.SortID >= mode.SortID) { sortID++; DbDataLoader.UpdateParamSort(param.ID, sortID); } } if (DbDataLoader.Add(mode) > 0) { BindGrid(mode.SlnID, mode.VerID, mode.ContractID); txtField.Text = ""; txtRemark.Text = ""; } else { Alert("增加失败!", GetUrl()); } } catch (Exception ex) { TraceLog.WriteError("Default ParamAdd error:{0}", ex); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ParamInfoModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ParamInfo("); strSql.Append("SlnID,ContractID,ParamType,Field,FieldType,Descption,FieldValue,Required,Remark,SortID,Creator,Modifier,MinValue,MaxValue)"); strSql.Append(" values ("); strSql.Append("@SlnID,@ContractID,@ParamType,@Field,@FieldType,@Descption,@FieldValue,@Required,@Remark,@SortID,@Creator,@Modifier,@MinValue,@MaxValue)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@SlnID", SqlDbType.Int, 4), new SqlParameter("@ContractID", SqlDbType.Int, 4), new SqlParameter("@ParamType", SqlDbType.SmallInt, 2), new SqlParameter("@Field", SqlDbType.VarChar, 30), new SqlParameter("@FieldType", SqlDbType.SmallInt, 2), new SqlParameter("@Descption", SqlDbType.VarChar, 100), new SqlParameter("@FieldValue", SqlDbType.VarChar, 100), new SqlParameter("@Required", SqlDbType.Bit, 1), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@SortID", SqlDbType.Int, 4), new SqlParameter("@Creator", SqlDbType.Int, 4), new SqlParameter("@Modifier", SqlDbType.Int, 4), new SqlParameter("@MinValue", SqlDbType.Int, 4), new SqlParameter("@MaxValue", SqlDbType.Int, 4) }; parameters[0].Value = model.SlnID; parameters[1].Value = model.ContractID; parameters[2].Value = model.ParamType; parameters[3].Value = model.Field; parameters[4].Value = model.FieldType; parameters[5].Value = model.Descption; parameters[6].Value = model.FieldValue; parameters[7].Value = model.Required; parameters[8].Value = model.Remark; parameters[9].Value = model.SortID; parameters[10].Value = model.Creator; parameters[11].Value = model.Modifier; parameters[12].Value = model.MinValue; parameters[13].Value = model.MaxValue; object obj = SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public static bool CopyContract(int slnID, int contractID, int copySlnID, int copyContractID) { var contract = GetContract(slnID, contractID, 0); 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, 0); 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 btnParamAdd_Click(object sender, EventArgs e) { try { ParamInfoModel mode = new ParamInfoModel(); mode.Field = txtField.Text.Trim(); mode.FieldValue = ""; mode.Remark = txtRemark.Text.Trim(); mode.ContractID = ddContract.Text.ToInt(); mode.FieldType = ddFieldType.Text.ToEnum <FieldType>(); mode.ParamType = ddParamType.Text.ToInt(); mode.Required = ckRequired.Checked; mode.Descption = ""; mode.SlnID = ddlSolution.Text.ToInt(); mode.MinValue = 0; mode.MaxValue = 0; mode.CreateDate = DateTime.Now; mode.VerID = ddVersion.Text.ToInt(); var paramList = DbDataLoader.GetParamInfo(mode.SlnID, mode.ContractID, mode.ParamType, mode.VerID).OrderBy(p => p.SortID).ToList(); if (paramList.Count == 0 || paramList[0].SortID == 0) { mode.SortID = 1; } else { int SortID = paramList[paramList.Count - 1].SortID; SortID++; mode.SortID = SortID; } if (DbDataLoader.Add(mode) > 0) { BindGrid(mode.SlnID, mode.VerID, mode.ContractID); txtField.Text = ""; txtRemark.Text = ""; } else { Response.Write("<script language=javascript>alert('增加失败!')</script>"); } } catch (Exception ex) { TraceLog.WriteError("Default ParamAdd error:{0}", ex); } }
protected void OnGridRowUpdating(object sender, GridViewUpdateEventArgs e) { try { var gv = sender as GridView; if (gv == null) { return; } var keys = gv.DataKeys[e.RowIndex]; TableCell cell = gv.Rows[e.RowIndex].Cells[0]; ParamInfoModel mode = new ParamInfoModel(); mode.ID = keys.Value.ToInt(); mode.ContractID = ddContract.Text.ToInt(); mode.ParamType = keys.Values[1].ToInt(); mode.Field = ((TextBox)cell.FindControl("txtField")).Text.Trim(); mode.FieldType = ((DropDownList)cell.FindControl("droFieldType")).SelectedValue.ToEnum <FieldType>(); mode.Remark = JoinArray(',', ((TextBox)cell.FindControl("hiDescption")).Text.Trim(), ((TextBox)cell.FindControl("txtDescption")).Text.Trim());//合并到Remark字段 mode.Descption = ""; var fieldVlue = ((TextBox)cell.FindControl("txtFieldValue")); if (fieldVlue != null) { mode.FieldValue = fieldVlue.Text.Trim(); } var conRequired = (DropDownList)cell.FindControl("droRequired"); if (conRequired != null) { mode.Required = Convert.ToBoolean(conRequired.Text); } mode.SortID = -1; mode.ModifyDate = MathUtils.Now; if (DbDataLoader.Update(mode)) { gv.EditIndex = -1; BindResult(); } } catch (Exception erro) { TraceLog.WriteError("RowUpdating:{0}", erro); Response.Write("错误信息:" + erro.Message); } }
public static List <ParamInfoModel> GetParamInfo(Action <CommandFilter> match) { var command = _dbBaseProvider.CreateCommandStruct("ParamInfo", CommandMode.Inquiry); command.Columns = "ID,SlnID,ContractID,ParamType,Field,FieldType,Descption,FieldValue,Required,Remark,SortID,Creator,CreateDate,Modifier,ModifyDate,MinValue,MaxValue,VerID"; command.OrderBy = "PARAMTYPE ASC,SORTID ASC,ID ASC"; command.Filter = _dbBaseProvider.CreateCommandFilter(); if (match != null) { match(command.Filter); } command.Parser(); var list = new List <ParamInfoModel>(); using (var reader = _dbBaseProvider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters)) { while (reader.Read()) { ParamInfoModel model = new ParamInfoModel(); model.ID = reader["ID"].ToInt(); model.SlnID = reader["SlnID"].ToInt(); model.ContractID = reader["ContractID"].ToInt(); model.ParamType = reader["ParamType"].ToInt(); model.Field = reader["Field"].ToNotNullString(); model.FieldType = reader["FieldType"].ToEnum <FieldType>(); model.Descption = reader["Descption"].ToNotNullString(); model.FieldValue = reader["FieldValue"].ToNotNullString(); model.Required = reader["Required"].ToBool(); model.Remark = reader["Remark"].ToNotNullString(); model.SortID = reader["SortID"].ToInt(); model.Creator = reader["Creator"].ToInt(); model.CreateDate = reader["CreateDate"].ToDateTime(); model.Modifier = reader["Modifier"].ToInt(); model.ModifyDate = reader["ModifyDate"].ToDateTime(); model.MinValue = reader["MinValue"].ToInt(); model.MaxValue = reader["MaxValue"].ToInt(); model.VerID = reader["VerID"].ToInt(); list.Add(model); } } return(list); }
public static bool Delete(ParamInfoModel model) { var command = _dbBaseProvider.CreateCommandStruct("ParamInfo", CommandMode.Delete); command.Filter = _dbBaseProvider.CreateCommandFilter(); if (model.SlnID > 0 && model.ContractID > 0) { command.Filter.Condition = string.Format("{0} AND {1}", _dbBaseProvider.FormatFilterParam("ContractID"), _dbBaseProvider.FormatFilterParam("SlnID")); command.Filter.AddParam("ContractID", model.ContractID); command.Filter.AddParam("SlnID", model.SlnID); } else { command.Filter.Condition = _dbBaseProvider.FormatFilterParam("ID"); command.Filter.AddParam("ID", model.ID); } command.Parser(); return(_dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0); }
protected void btnSubmit_Click(object sender, EventArgs e) { ParamInfoModel mode = new ParamInfoModel(); ParamInfoBLL BLL = new ParamInfoBLL(); mode.Field = txtField.Text.Trim(); mode.FieldValue = txtFieldValue.Text.Trim(); mode.Remark = txtRemark.Text.Trim(); mode.ContractID = ContractID; mode.FieldType = Convert.ToInt32(droFieldType.SelectedValue); mode.ParamType = Convert.ToInt32(droParamType.SelectedValue); mode.Required = Convert.ToBoolean(droRrequired.SelectedValue); mode.Descption = txtDescption.Text.Trim(); mode.SlnID = SlnID; mode.MinValue = Convert.ToInt32(txtMinValue.Text.Trim()); mode.MaxValue = Convert.ToInt32(txtMaxValue.Text.Trim()); DataSet ds = BLL.GetID(string.Format("ContractID={0} and slnid={1} and ParamType={2}", ContractID, SlnID, mode.ParamType)); if (ds.Tables[0].Rows[0]["SortID"].ToString() == "") { mode.SortID = 1; } else { int SortID = Convert.ToInt32(ds.Tables[0].Rows[0]["SortID"]); SortID++; mode.SortID = SortID; } if (BLL.Add(mode) != 0) { Response.Redirect(String.Format("index.aspx?ID={0}&slnID={1}", ContractID, mode.SlnID)); } else { Response.Write("<script language=javascript>alert('增加失败!')</script>"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { ParamInfoModel mode = new ParamInfoModel(); mode.Field = txtField.Text.Trim(); mode.FieldValue = txtFieldValue.Text.Trim(); mode.Remark = txtRemark.Text.Trim(); mode.ContractID = ContractID; mode.FieldType = droFieldType.SelectedValue.ToEnum <FieldType>(); mode.ParamType = Convert.ToInt32((string)droParamType.SelectedValue); mode.Required = Convert.ToBoolean((string)droRrequired.SelectedValue); mode.Descption = txtDescption.Text.Trim(); mode.SlnID = SlnID; mode.MinValue = Convert.ToInt32((string)txtMinValue.Text.Trim()); mode.MaxValue = Convert.ToInt32((string)txtMaxValue.Text.Trim()); mode.CreateDate = DateTime.Now; var paramList = DbDataLoader.GetParamInfo(SlnID, ContractID, mode.ParamType).OrderBy(p => p.SortID).ToList(); if (paramList.Count == 0 || paramList[0].SortID == 0) { mode.SortID = 1; } else { int SortID = paramList[paramList.Count - 1].SortID; SortID++; mode.SortID = SortID; } if (DbDataLoader.Add(mode) > 0) { Response.Redirect(String.Format("index.aspx?ID={0}&slnID={1}", ContractID, mode.SlnID)); } else { Response.Write("<script language=javascript>alert('增加失败!')</script>"); } }
public static bool Update(ParamInfoModel model) { var command = _dbBaseProvider.CreateCommandStruct("ParamInfo", CommandMode.Modify); if (model.SlnID > 0) { command.AddParameter("SlnID", model.SlnID); } command.AddParameter("ContractID", model.ContractID); command.AddParameter("ParamType", model.ParamType); command.AddParameter("Field", model.Field); command.AddParameter("FieldType", model.FieldType); command.AddParameter("Descption", model.Descption); if (!string.IsNullOrEmpty(model.FieldValue)) { command.AddParameter("FieldValue", model.FieldValue); } command.AddParameter("Required", model.Required); command.AddParameter("Remark", model.Remark); if (model.SortID > -1) { command.AddParameter("SortID", model.SortID); } command.AddParameter("Creator", model.Creator); command.AddParameter("Modifier", model.Modifier); command.AddParameter("MinValue", model.MinValue); command.AddParameter("MaxValue", model.MaxValue); command.AddParameter("ModifyDate", model.ModifyDate); if (model.VerID > 0) { command.AddParameter("VerID", model.VerID); } 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); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ParamInfoModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ParamInfo set "); strSql.Append("ContractID=@ContractID,"); strSql.Append("ParamType=@ParamType,"); strSql.Append("Field=@Field,"); strSql.Append("FieldType=@FieldType,"); strSql.Append("Descption=@Descption,"); strSql.Append("FieldValue=@FieldValue,"); strSql.Append("Required=@Required,"); strSql.Append("Remark=@Remark,"); strSql.Append("SortID=@SortID,"); strSql.Append("Creator=@Creator,"); strSql.Append("Modifier=@Modifier,"); strSql.Append("MinValue=@MinValue,"); strSql.Append("MaxValue=@MaxValue,"); strSql.Append("ModifyDate=@ModifyDate"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ContractID", SqlDbType.Int, 4), new SqlParameter("@ParamType", SqlDbType.SmallInt, 2), new SqlParameter("@Field", SqlDbType.VarChar, 30), new SqlParameter("@FieldType", SqlDbType.SmallInt, 2), new SqlParameter("@Descption", SqlDbType.VarChar, 100), new SqlParameter("@FieldValue", SqlDbType.VarChar, 100), new SqlParameter("@Required", SqlDbType.Bit, 1), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@SortID", SqlDbType.Int, 4), new SqlParameter("@Creator", SqlDbType.Int, 4), new SqlParameter("@Modifier", SqlDbType.Int, 4), new SqlParameter("@MinValue", SqlDbType.Int, 4), new SqlParameter("@MaxValue", SqlDbType.Int, 4), new SqlParameter("@ModifyDate", SqlDbType.DateTime), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.ContractID; parameters[1].Value = model.ParamType; parameters[2].Value = model.Field; parameters[3].Value = model.FieldType; parameters[4].Value = model.Descption; parameters[5].Value = model.FieldValue; parameters[6].Value = model.Required; parameters[7].Value = model.Remark; parameters[8].Value = model.SortID; parameters[9].Value = model.Creator; parameters[10].Value = model.Modifier; parameters[11].Value = model.MinValue; parameters[12].Value = model.MaxValue; parameters[13].Value = model.ModifyDate; parameters[14].Value = model.ID; int rows = SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }