public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtF_ParentID.Text.Trim().Length == 0) { strErr += "F_ParentID不能为空!\\n"; } if (this.txtF_Value.Text.Trim().Length == 0) { strErr += "F_Value不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string F_DicID = this.lblF_DicID.Text; string F_ParentID = this.txtF_ParentID.Text; string F_Value = this.txtF_Value.Text; bool F_IsUsed = this.chkF_IsUsed.Checked; WSS.Model.Dictionary model = new WSS.Model.Dictionary(); model.F_DicID = F_DicID; model.F_ParentID = F_ParentID; model.F_Value = F_Value; model.F_IsUsed = F_IsUsed; WSS.BLL.Dictionary bll = new WSS.BLL.Dictionary(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WSS.Model.Dictionary model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Dictionary set "); strSql.Append("F_ParentID=@F_ParentID,"); strSql.Append("F_Value=@F_Value,"); strSql.Append("F_IsUsed=@F_IsUsed,"); strSql.Append("F_Sort=@F_Sort"); strSql.Append(" where F_DicID=@F_DicID "); SqlParameter[] parameters = { new SqlParameter("@F_ParentID", SqlDbType.Int, 4), new SqlParameter("@F_Value", SqlDbType.NVarChar, 50), new SqlParameter("@F_IsUsed", SqlDbType.Bit, 1), new SqlParameter("@F_Sort", SqlDbType.Int, 4), new SqlParameter("@F_DicID", SqlDbType.Int, 4) }; parameters[0].Value = model.F_ParentID; parameters[1].Value = model.F_Value; parameters[2].Value = model.F_IsUsed; parameters[3].Value = model.F_Sort; parameters[4].Value = model.F_DicID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo(string F_DicID) { WSS.BLL.Dictionary bll = new WSS.BLL.Dictionary(); WSS.Model.Dictionary model = bll.GetModel(F_DicID); this.lblF_DicID.Text = model.F_DicID; this.txtF_ParentID.Text = model.F_ParentID; this.txtF_Value.Text = model.F_Value; this.chkF_IsUsed.Checked = model.F_IsUsed; }
private void ShowInfo(string F_DicID) { WSS.BLL.Dictionary bll = new WSS.BLL.Dictionary(); WSS.Model.Dictionary model = bll.GetModel(F_DicID); this.lblF_DicID.Text = model.F_DicID; this.lblF_ParentID.Text = model.F_ParentID; this.lblF_Value.Text = model.F_Value; this.lblF_IsUsed.Text = model.F_IsUsed?"ÊÇ":"·ñ"; }
/// <summary> /// 得到一个对象实体 /// </summary> public WSS.Model.Dictionary GetModel(int F_DicID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 F_DicID,F_ParentID,F_Value,F_IsUsed,F_Sort from T_Dictionary "); strSql.Append(" where F_DicID=@F_DicID "); SqlParameter[] parameters = { new SqlParameter("@F_DicID", SqlDbType.Int, 4) }; parameters[0].Value = F_DicID; WSS.Model.Dictionary model = new WSS.Model.Dictionary(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["F_DicID"].ToString() != "") { model.F_DicID = int.Parse(ds.Tables[0].Rows[0]["F_DicID"].ToString()); } if (ds.Tables[0].Rows[0]["F_ParentID"].ToString() != "") { model.F_ParentID = int.Parse(ds.Tables[0].Rows[0]["F_ParentID"].ToString()); } if (ds.Tables[0].Rows[0]["F_Value"] != null) { model.F_Value = ds.Tables[0].Rows[0]["F_Value"].ToString(); } if (ds.Tables[0].Rows[0]["F_IsUsed"].ToString() != "") { if ((ds.Tables[0].Rows[0]["F_IsUsed"].ToString() == "1") || (ds.Tables[0].Rows[0]["F_IsUsed"].ToString().ToLower() == "true")) { model.F_IsUsed = true; } else { model.F_IsUsed = false; } } if (ds.Tables[0].Rows[0]["F_Sort"].ToString() != "") { model.F_Sort = int.Parse(ds.Tables[0].Rows[0]["F_Sort"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 获得数据列表 /// </summary> public List <WSS.Model.Dictionary> DataTableToList(DataTable dt) { List <WSS.Model.Dictionary> modelList = new List <WSS.Model.Dictionary>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { WSS.Model.Dictionary model; for (int n = 0; n < rowsCount; n++) { model = new WSS.Model.Dictionary(); if (dt.Rows[n]["F_DicID"].ToString() != "") { model.F_DicID = int.Parse(dt.Rows[n]["F_DicID"].ToString()); } if (dt.Rows[n]["F_ParentID"].ToString() != "") { model.F_ParentID = int.Parse(dt.Rows[n]["F_ParentID"].ToString()); } model.F_Value = dt.Rows[n]["F_Value"].ToString(); if (dt.Rows[n]["F_IsUsed"].ToString() != "") { if ((dt.Rows[n]["F_IsUsed"].ToString() == "1") || (dt.Rows[n]["F_IsUsed"].ToString().ToLower() == "true")) { model.F_IsUsed = true; } else { model.F_IsUsed = false; } } if (dt.Rows[n]["F_Sort"].ToString() != "") { model.F_Sort = int.Parse(dt.Rows[n]["F_Sort"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(WSS.Model.Dictionary model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Dictionary("); strSql.Append("F_DicID,F_ParentID,F_Value,F_IsUsed,F_Sort)"); strSql.Append(" values ("); strSql.Append("@F_DicID,@F_ParentID,@F_Value,@F_IsUsed,@F_Sort)"); SqlParameter[] parameters = { new SqlParameter("@F_DicID", SqlDbType.Int, 4), new SqlParameter("@F_ParentID", SqlDbType.Int, 4), new SqlParameter("@F_Value", SqlDbType.NVarChar, 50), new SqlParameter("@F_IsUsed", SqlDbType.Bit, 1), new SqlParameter("@F_Sort", SqlDbType.Int, 4) }; parameters[0].Value = model.F_DicID; parameters[1].Value = model.F_ParentID; parameters[2].Value = model.F_Value; parameters[3].Value = model.F_IsUsed; parameters[4].Value = model.F_Sort; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WSS.Model.Dictionary model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(WSS.Model.Dictionary model) { dal.Add(model); }