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); 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("Modifier", model.Modifier); command.AddParameter("MinValue", model.MinValue); command.AddParameter("MaxValue", model.MaxValue); command.AddParameter("ModifyDate", model.ModifyDate); 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; }
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 = DateTime.Now; if (DbDataLoader.Update(mode)) { gvGetlist.EditIndex = -1; QueryResult(); } } catch (Exception erro) { Response.Write("错误信息:" + erro.Message); } finally { } }
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; }
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"; 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(); list.Add(model); } } return list; }
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); }
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 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 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); } }
private static void BuildMemberCode(StringBuilder memberBuilder, string spaceString, ParamInfoModel paramInfo, bool isClassMember = false) { string descp = paramInfo.Descption + paramInfo.Remark; memberBuilder.AppendLine("/// <summary>"); memberBuilder.Append(spaceString); memberBuilder.AppendLine("/// " + descp.Replace("\r\n", ",")); memberBuilder.Append(spaceString); memberBuilder.AppendLine("/// </summary>"); memberBuilder.Append(spaceString); if (isClassMember) { memberBuilder.AppendFormat("public {0} {1}", paramInfo.FieldType == FieldType.Password ? "string" : paramInfo.FieldType.ToString().ToLower(), paramInfo.Field); memberBuilder.AppendLine(" { get; set; }"); } else { memberBuilder.AppendFormat("private {0} {1}", paramInfo.FieldType == FieldType.Password ? "string" : paramInfo.FieldType.ToString().ToLower(), ToMemberVarName(paramInfo.Field)); memberBuilder.AppendLine(";"); } memberBuilder.Append(spaceString); }
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>"); } }
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); } }