protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtorgId.Text.Trim().Length == 0) { strErr += "orgId不能为空!\\n"; } if (this.txtfunctionGroup.Text.Trim().Length == 0) { strErr += "functionGroup不能为空!\\n"; } if (this.txtfunctionCode.Text.Trim().Length == 0) { strErr += "functionCode不能为空!\\n"; } if (this.txtfunctionName.Text.Trim().Length == 0) { strErr += "functionName不能为空!\\n"; } if (this.txtfunctionPath.Text.Trim().Length == 0) { strErr += "functionPath不能为空!\\n"; } if (this.txtmemo.Text.Trim().Length == 0) { strErr += "memo不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string orgId = this.txtorgId.Text; string functionGroup = this.txtfunctionGroup.Text; string functionCode = this.txtfunctionCode.Text; string functionName = this.txtfunctionName.Text; string functionPath = this.txtfunctionPath.Text; string memo = this.txtmemo.Text; yinxiang.Model.smes_functionName_new model = new yinxiang.Model.smes_functionName_new(); model.orgId = orgId; model.functionGroup = functionGroup; model.functionCode = functionCode; model.functionName = functionName; model.functionPath = functionPath; model.memo = memo; yinxiang.BLL.smes_functionName_new bll = new yinxiang.BLL.smes_functionName_new(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
private void ShowInfo(long functionid) { yinxiang.BLL.smes_functionName_new bll = new yinxiang.BLL.smes_functionName_new(); yinxiang.Model.smes_functionName_new model = bll.GetModel(functionid); this.lblfunctionid.Text = model.functionid.ToString(); this.txtorgId.Text = model.orgId; this.txtfunctionGroup.Text = model.functionGroup; this.lblfunctionCode.Text = model.functionCode; this.txtfunctionName.Text = model.functionName; this.txtfunctionPath.Text = model.functionPath; this.txtmemo.Text = model.memo; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(yinxiang.Model.smes_functionName_new model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update smes_functionName_new set "); strSql.Append("orgId=@orgId,"); strSql.Append("functionGroup=@functionGroup,"); strSql.Append("functionName=@functionName,"); strSql.Append("functionPath=@functionPath,"); strSql.Append("memo=@memo"); strSql.Append(" where functionid=@functionid"); SqlParameter[] parameters = { new SqlParameter("@orgId", SqlDbType.VarChar, 50), new SqlParameter("@functionGroup", SqlDbType.VarChar, 50), new SqlParameter("@functionName", SqlDbType.VarChar, 50), new SqlParameter("@functionPath", SqlDbType.VarChar, 250), new SqlParameter("@memo", SqlDbType.VarChar, 500), new SqlParameter("@functionid", SqlDbType.BigInt, 8), new SqlParameter("@functionCode", SqlDbType.VarChar, 50) }; parameters[0].Value = model.orgId; parameters[1].Value = model.functionGroup; parameters[2].Value = model.functionName; parameters[3].Value = model.functionPath; parameters[4].Value = model.memo; parameters[5].Value = model.functionid; parameters[6].Value = model.functionCode; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public long Add(yinxiang.Model.smes_functionName_new model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into smes_functionName_new("); strSql.Append("orgId,functionGroup,functionCode,functionName,functionPath,memo)"); strSql.Append(" values ("); strSql.Append("@orgId,@functionGroup,@functionCode,@functionName,@functionPath,@memo)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@orgId", SqlDbType.VarChar, 50), new SqlParameter("@functionGroup", SqlDbType.VarChar, 50), new SqlParameter("@functionCode", SqlDbType.VarChar, 50), new SqlParameter("@functionName", SqlDbType.VarChar, 50), new SqlParameter("@functionPath", SqlDbType.VarChar, 250), new SqlParameter("@memo", SqlDbType.VarChar, 500) }; parameters[0].Value = model.orgId; parameters[1].Value = model.functionGroup; parameters[2].Value = model.functionCode; parameters[3].Value = model.functionName; parameters[4].Value = model.functionPath; parameters[5].Value = model.memo; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt64(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public yinxiang.Model.smes_functionName_new DataRowToModel(DataRow row) { yinxiang.Model.smes_functionName_new model = new yinxiang.Model.smes_functionName_new(); if (row != null) { if (row["functionid"] != null && row["functionid"].ToString() != "") { model.functionid = long.Parse(row["functionid"].ToString()); } if (row["orgId"] != null) { model.orgId = row["orgId"].ToString(); } if (row["functionGroup"] != null) { model.functionGroup = row["functionGroup"].ToString(); } if (row["functionCode"] != null) { model.functionCode = row["functionCode"].ToString(); } if (row["functionName"] != null) { model.functionName = row["functionName"].ToString(); } if (row["functionPath"] != null) { model.functionPath = row["functionPath"].ToString(); } if (row["memo"] != null) { model.memo = row["memo"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public yinxiang.Model.smes_functionName_new GetModel(long functionid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 functionid,orgId,functionGroup,functionCode,functionName,functionPath,memo from smes_functionName_new "); strSql.Append(" where functionid=@functionid"); SqlParameter[] parameters = { new SqlParameter("@functionid", SqlDbType.BigInt) }; parameters[0].Value = functionid; yinxiang.Model.smes_functionName_new model = new yinxiang.Model.smes_functionName_new(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }