/// <summary> /// 更新一条数据 /// </summary> public void Update(DigiPower.Onlinecol.Standard.Model.T_DefineReult_MDL model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_DefineReult set "); strSql.Append("CanDefineTypeID=@CanDefineTypeID,"); strSql.Append("OrderIndex=@OrderIndex,"); strSql.Append("SplitID=@SplitID,"); strSql.Append("FileType_DEL=@FileType_DEL,"); strSql.Append("CutLength=@CutLength"); strSql.Append(" where DefineResultID=@DefineResultID "); SqlParameter[] parameters = { new SqlParameter("@DefineResultID", SqlDbType.Int, 8), new SqlParameter("@CanDefineTypeID", SqlDbType.Int, 8), new SqlParameter("@OrderIndex", SqlDbType.Int, 8), new SqlParameter("@SplitID", SqlDbType.Int, 8), new SqlParameter("@FileType_DEL", SqlDbType.NVarChar, 50), new SqlParameter("@CutLength", SqlDbType.Int, 8) }; parameters[0].Value = model.DefineResultID; parameters[1].Value = model.CanDefineTypeID; parameters[2].Value = model.OrderIndex; parameters[3].Value = model.SplitID; parameters[4].Value = model.FileType_DEL; parameters[5].Value = model.CutLength; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DigiPower.Onlinecol.Standard.Model.T_DefineReult_MDL model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_DefineReult("); strSql.Append("CanDefineTypeID,OrderIndex,SplitID,FileType_DEL,CutLength)"); strSql.Append(" values ("); strSql.Append("@CanDefineTypeID,@OrderIndex,@SplitID,@FileType_DEL,@CutLength)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CanDefineTypeID", SqlDbType.Int, 8), new SqlParameter("@OrderIndex", SqlDbType.Int, 8), new SqlParameter("@SplitID", SqlDbType.Int, 8), new SqlParameter("@FileType_DEL", SqlDbType.NVarChar, 50), new SqlParameter("@CutLength", SqlDbType.Int, 8) }; parameters[0].Value = model.CanDefineTypeID; parameters[1].Value = model.OrderIndex; parameters[2].Value = model.SplitID; parameters[3].Value = model.FileType_DEL; parameters[4].Value = model.CutLength; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 绑定页面 /// </summary> /// <param name="ID"></param> private void BindPage(string ID) { Model.T_DefineReult_MDL model = new DigiPower.Onlinecol.Standard.Model.T_DefineReult_MDL(); BLL.T_DefineReult_BLL bll = new DigiPower.Onlinecol.Standard.BLL.T_DefineReult_BLL(); model = bll.GetModel(DigiPower.Onlinecol.Standard.Common.ConvertEx.ToInt(ID)); if (model != null) { DigiPower.Onlinecol.Standard.Web.Comm.SetValueToPage(model, this.tbl); ViewState["model"] = model; // this.CanDefineTypeID.SelectValue = model.CanDefineTypeID.ToString(); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DigiPower.Onlinecol.Standard.Model.T_DefineReult_MDL GetModel(int DefineResultID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 DefineResultID,CanDefineTypeID,OrderIndex,SplitID,FileType_DEL,CutLength from T_DefineReult "); strSql.Append(" where DefineResultID=@DefineResultID "); SqlParameter[] parameters = { new SqlParameter("@DefineResultID", SqlDbType.Int, 8) }; parameters[0].Value = DefineResultID; DigiPower.Onlinecol.Standard.Model.T_DefineReult_MDL model = new DigiPower.Onlinecol.Standard.Model.T_DefineReult_MDL(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["DefineResultID"].ToString() != "") { model.DefineResultID = int.Parse(ds.Tables[0].Rows[0]["DefineResultID"].ToString()); } if (ds.Tables[0].Rows[0]["CanDefineTypeID"].ToString() != "") { model.CanDefineTypeID = int.Parse(ds.Tables[0].Rows[0]["CanDefineTypeID"].ToString()); } if (ds.Tables[0].Rows[0]["OrderIndex"].ToString() != "") { model.OrderIndex = int.Parse(ds.Tables[0].Rows[0]["OrderIndex"].ToString()); } if (ds.Tables[0].Rows[0]["SplitID"].ToString() != "") { model.SplitID = int.Parse(ds.Tables[0].Rows[0]["SplitID"].ToString()); } model.FileType_DEL = ds.Tables[0].Rows[0]["FileType_DEL"].ToString(); if (ds.Tables[0].Rows[0]["CutLength"].ToString() != "") { model.CutLength = int.Parse(ds.Tables[0].Rows[0]["CutLength"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { Model.T_DefineReult_MDL model = new DigiPower.Onlinecol.Standard.Model.T_DefineReult_MDL(); BLL.T_DefineReult_BLL bll = new DigiPower.Onlinecol.Standard.BLL.T_DefineReult_BLL(); if (ViewState["model"] != null) { model = (Model.T_DefineReult_MDL)ViewState["model"]; } object obj = Comm.GetValueToObject(model, this.tbl); if (obj != null) { Model.T_DefineReult_MDL Newmodel = (Model.T_DefineReult_MDL)obj; switch ((CommonEnum.PageState)ViewState["ps"]) { case CommonEnum.PageState.ADD: Newmodel.CanDefineTypeID = DigiPower.Onlinecol.Standard.Common.ConvertEx.ToInt(this.CanDefineTypeID.SelectValue); Newmodel.SplitID = DigiPower.Onlinecol.Standard.Common.ConvertEx.ToInt(this.SplitID.SelectValue); bll.Add(Newmodel); break; case CommonEnum.PageState.EDIT: { Newmodel.DefineResultID = DigiPower.Onlinecol.Standard.Common.ConvertEx.ToInt(ID); bll.Update(Newmodel); } break; } } Response.Redirect("DefinedList.aspx?sqlwhere=" + SqlWhere + "&PageIndex=" + pPageIndex + ""); }