//保存数据 protected void Save_btn_Click(object sender, EventArgs e) { //获取页面信息 string stocode = Helper.GetAppSettings("Stocode"); string buscode = Helper.GetAppSettings("BusCode"); string key = txt_key.Text; string val = txt_val.Text; string status = this.ddl_status.SelectedValue; string descr = txt_descr.Value; string explain = txt_explain.Value; if (hidId.Value.Length == 0)//添加信息 { bll.Add("0", "0", "", stocode, buscode, key, val, status, descr, explain); hidId.Value = bll.oResult.Data; this.PageTitle.Operate = "修改"; } else//修改信息 { ts_syssetEntity UEntity = bll.GetEntitySigInfo(" where setid=" + hidId.Value); UEntity.buscode = buscode; UEntity.stocode = stocode; UEntity.key = key; UEntity.val = val; UEntity.status = StringHelper.StringToInt(status); UEntity.descr = descr; UEntity.explain = explain; bll.Update("0", "0", UEntity); } //显示结果 ShowResult(bll.oResult.Code, bll.oResult.Msg, errormessage); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(string GUID, string UID, ts_syssetEntity UEntity) { //更新数据 int result = dal.Update(UEntity); //检测执行结果 CheckResult(result, ""); }
/// <summary> /// 单行数据转实体对象 /// </summary> /// <param name="dr"></param> /// <returns></returns> private ts_syssetEntity SetEntityInfo(DataRow dr) { ts_syssetEntity Entity = new ts_syssetEntity(); Entity.setid = StringHelper.StringToInt(dr["setid"].ToString()); Entity.stocode = dr["stocode"].ToString(); //Entity.buscode = dr["buscode"].ToString(); Entity.key = dr["key"].ToString(); Entity.val = dr["val"].ToString(); Entity.status = StringHelper.StringToInt(dr["status"].ToString()); Entity.descr = dr["descr"].ToString(); return(Entity); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(ts_syssetEntity Entity) { SqlParameter[] sqlParameters = { new SqlParameter("@setid", Entity.setid), new SqlParameter("@stocode", Entity.stocode), new SqlParameter("@buscode", Entity.buscode), new SqlParameter("@key", Entity.key), new SqlParameter("@val", Entity.val), new SqlParameter("@status", Entity.status), new SqlParameter("@descr", Entity.descr), new SqlParameter("@explain", Entity.explain) }; return(DBHelper.ExecuteNonQuery("dbo.p_ts_sysset_Update", CommandType.StoredProcedure, sqlParameters)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ref ts_syssetEntity Entity) { intReturn = 0; SqlParameter[] sqlParameters = { new SqlParameter("@setid", Entity.setid), new SqlParameter("@stocode", Entity.stocode), new SqlParameter("@buscode", Entity.buscode), new SqlParameter("@key", Entity.key), new SqlParameter("@val", Entity.val), new SqlParameter("@status", Entity.status), new SqlParameter("@descr", Entity.descr), new SqlParameter("@explain", Entity.explain) }; sqlParameters[0].Direction = ParameterDirection.Output; intReturn = DBHelper.ExecuteNonQuery("dbo.p_ts_sysset_Add", CommandType.StoredProcedure, sqlParameters); if (intReturn == 0) { Entity.setid = int.Parse(sqlParameters[0].Value.ToString()); } return(intReturn); }
/// <summary> /// 检验表单数据 /// </summary> /// <returns></returns> public bool CheckPageInfo(string type, string setid, string stocode, string buscode, string key, string val, string status, string descr, string explain) { bool rel = false; try { Entity = new ts_syssetEntity(); Entity.setid = StringHelper.StringToInt(setid); Entity.stocode = stocode; Entity.key = key; Entity.val = val; Entity.status = StringHelper.StringToInt(status); Entity.descr = descr; Entity.explain = explain; rel = true; } catch (System.Exception) { throw; } return(rel); }