/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.sys_Event DataRowToModel(DataRow row) { Maticsoft.Model.sys_Event model = new Maticsoft.Model.sys_Event(); if (row != null) { if (row["EventID"] != null && row["EventID"].ToString() != "") { model.EventID = int.Parse(row["EventID"].ToString()); } if (row["E_U_LoginName"] != null) { model.E_U_LoginName = row["E_U_LoginName"].ToString(); } if (row["E_UserID"] != null && row["E_UserID"].ToString() != "") { model.E_UserID = int.Parse(row["E_UserID"].ToString()); } if (row["E_DateTime"] != null && row["E_DateTime"].ToString() != "") { model.E_DateTime = DateTime.Parse(row["E_DateTime"].ToString()); } if (row["E_ApplicationID"] != null && row["E_ApplicationID"].ToString() != "") { model.E_ApplicationID = int.Parse(row["E_ApplicationID"].ToString()); } if (row["E_A_AppName"] != null) { model.E_A_AppName = row["E_A_AppName"].ToString(); } if (row["E_M_Name"] != null) { model.E_M_Name = row["E_M_Name"].ToString(); } if (row["E_M_PageCode"] != null) { model.E_M_PageCode = row["E_M_PageCode"].ToString(); } if (row["E_From"] != null) { model.E_From = row["E_From"].ToString(); } if (row["E_Type"] != null && row["E_Type"].ToString() != "") { model.E_Type = int.Parse(row["E_Type"].ToString()); } if (row["E_IP"] != null) { model.E_IP = row["E_IP"].ToString(); } if (row["E_Record"] != null) { model.E_Record = row["E_Record"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.sys_Event DataRowToModel(DataRow row) { Maticsoft.Model.sys_Event model=new Maticsoft.Model.sys_Event(); if (row != null) { if(row["EventID"]!=null && row["EventID"].ToString()!="") { model.EventID=int.Parse(row["EventID"].ToString()); } if(row["E_U_LoginName"]!=null) { model.E_U_LoginName=row["E_U_LoginName"].ToString(); } if(row["E_UserID"]!=null && row["E_UserID"].ToString()!="") { model.E_UserID=int.Parse(row["E_UserID"].ToString()); } if(row["E_DateTime"]!=null && row["E_DateTime"].ToString()!="") { model.E_DateTime=DateTime.Parse(row["E_DateTime"].ToString()); } if(row["E_ApplicationID"]!=null && row["E_ApplicationID"].ToString()!="") { model.E_ApplicationID=int.Parse(row["E_ApplicationID"].ToString()); } if(row["E_A_AppName"]!=null) { model.E_A_AppName=row["E_A_AppName"].ToString(); } if(row["E_M_Name"]!=null) { model.E_M_Name=row["E_M_Name"].ToString(); } if(row["E_M_PageCode"]!=null) { model.E_M_PageCode=row["E_M_PageCode"].ToString(); } if(row["E_From"]!=null) { model.E_From=row["E_From"].ToString(); } if(row["E_Type"]!=null && row["E_Type"].ToString()!="") { model.E_Type=int.Parse(row["E_Type"].ToString()); } if(row["E_IP"]!=null) { model.E_IP=row["E_IP"].ToString(); } if(row["E_Record"]!=null) { model.E_Record=row["E_Record"].ToString(); } } return model; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.sys_Event model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update sys_Event set "); strSql.Append("E_U_LoginName=@E_U_LoginName,"); strSql.Append("E_UserID=@E_UserID,"); strSql.Append("E_DateTime=@E_DateTime,"); strSql.Append("E_ApplicationID=@E_ApplicationID,"); strSql.Append("E_A_AppName=@E_A_AppName,"); strSql.Append("E_M_Name=@E_M_Name,"); strSql.Append("E_M_PageCode=@E_M_PageCode,"); strSql.Append("E_From=@E_From,"); strSql.Append("E_Type=@E_Type,"); strSql.Append("E_IP=@E_IP,"); strSql.Append("E_Record=@E_Record"); strSql.Append(" where EventID=@EventID"); SqlParameter[] parameters = { new SqlParameter("@E_U_LoginName", SqlDbType.NVarChar, 20), new SqlParameter("@E_UserID", SqlDbType.Int, 4), new SqlParameter("@E_DateTime", SqlDbType.DateTime), new SqlParameter("@E_ApplicationID", SqlDbType.Int, 4), new SqlParameter("@E_A_AppName", SqlDbType.NVarChar, 50), new SqlParameter("@E_M_Name", SqlDbType.NVarChar, 50), new SqlParameter("@E_M_PageCode", SqlDbType.VarChar, 6), new SqlParameter("@E_From", SqlDbType.NVarChar, 500), new SqlParameter("@E_Type", SqlDbType.TinyInt, 1), new SqlParameter("@E_IP", SqlDbType.VarChar, 15), new SqlParameter("@E_Record", SqlDbType.NVarChar, 500), new SqlParameter("@EventID", SqlDbType.Int, 4) }; parameters[0].Value = model.E_U_LoginName; parameters[1].Value = model.E_UserID; parameters[2].Value = model.E_DateTime; parameters[3].Value = model.E_ApplicationID; parameters[4].Value = model.E_A_AppName; parameters[5].Value = model.E_M_Name; parameters[6].Value = model.E_M_PageCode; parameters[7].Value = model.E_From; parameters[8].Value = model.E_Type; parameters[9].Value = model.E_IP; parameters[10].Value = model.E_Record; parameters[11].Value = model.EventID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.sys_Event model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into sys_Event("); strSql.Append("E_U_LoginName,E_UserID,E_DateTime,E_ApplicationID,E_A_AppName,E_M_Name,E_M_PageCode,E_From,E_Type,E_IP,E_Record)"); strSql.Append(" values ("); strSql.Append("@E_U_LoginName,@E_UserID,@E_DateTime,@E_ApplicationID,@E_A_AppName,@E_M_Name,@E_M_PageCode,@E_From,@E_Type,@E_IP,@E_Record)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@E_U_LoginName", SqlDbType.NVarChar, 20), new SqlParameter("@E_UserID", SqlDbType.Int, 4), new SqlParameter("@E_DateTime", SqlDbType.DateTime), new SqlParameter("@E_ApplicationID", SqlDbType.Int, 4), new SqlParameter("@E_A_AppName", SqlDbType.NVarChar, 50), new SqlParameter("@E_M_Name", SqlDbType.NVarChar, 50), new SqlParameter("@E_M_PageCode", SqlDbType.VarChar, 6), new SqlParameter("@E_From", SqlDbType.NVarChar, 500), new SqlParameter("@E_Type", SqlDbType.TinyInt, 1), new SqlParameter("@E_IP", SqlDbType.VarChar, 15), new SqlParameter("@E_Record", SqlDbType.NVarChar, 500) }; parameters[0].Value = model.E_U_LoginName; parameters[1].Value = model.E_UserID; parameters[2].Value = model.E_DateTime; parameters[3].Value = model.E_ApplicationID; parameters[4].Value = model.E_A_AppName; parameters[5].Value = model.E_M_Name; parameters[6].Value = model.E_M_PageCode; parameters[7].Value = model.E_From; parameters[8].Value = model.E_Type; parameters[9].Value = model.E_IP; parameters[10].Value = model.E_Record; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int EventID) { Maticsoft.BLL.sys_Event bll = new Maticsoft.BLL.sys_Event(); Maticsoft.Model.sys_Event model = bll.GetModel(EventID); this.lblEventID.Text = model.EventID.ToString(); this.txtE_U_LoginName.Text = model.E_U_LoginName; this.txtE_UserID.Text = model.E_UserID.ToString(); this.txtE_DateTime.Text = model.E_DateTime.ToString(); this.txtE_ApplicationID.Text = model.E_ApplicationID.ToString(); this.txtE_A_AppName.Text = model.E_A_AppName; this.txtE_M_Name.Text = model.E_M_Name; this.txtE_M_PageCode.Text = model.E_M_PageCode; this.txtE_From.Text = model.E_From; this.txtE_Type.Text = model.E_Type.ToString(); this.txtE_IP.Text = model.E_IP; this.txtE_Record.Text = model.E_Record; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.sys_Event GetModel(int EventID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 EventID,E_U_LoginName,E_UserID,E_DateTime,E_ApplicationID,E_A_AppName,E_M_Name,E_M_PageCode,E_From,E_Type,E_IP,E_Record from sys_Event "); strSql.Append(" where EventID=@EventID"); SqlParameter[] parameters = { new SqlParameter("@EventID", SqlDbType.Int, 4) }; parameters[0].Value = EventID; Maticsoft.Model.sys_Event model = new Maticsoft.Model.sys_Event(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.sys_Event GetModel(int EventID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 EventID,E_U_LoginName,E_UserID,E_DateTime,E_ApplicationID,E_A_AppName,E_M_Name,E_M_PageCode,E_From,E_Type,E_IP,E_Record from sys_Event "); strSql.Append(" where EventID=@EventID"); SqlParameter[] parameters = { new SqlParameter("@EventID", SqlDbType.Int,4) }; parameters[0].Value = EventID; Maticsoft.Model.sys_Event model=new Maticsoft.Model.sys_Event(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtE_U_LoginName.Text.Trim().Length==0) { strErr+="用户名不能为空!\\n"; } if(!PageValidate.IsNumber(txtE_UserID.Text)) { strErr+="操作时用户ID与sys_Use格式错误!\\n"; } if(!PageValidate.IsDateTime(txtE_DateTime.Text)) { strErr+="事件发生的日期及时间格式错误!\\n"; } if(!PageValidate.IsNumber(txtE_ApplicationID.Text)) { strErr+="所属应用程序ID与sys_Ap格式错误!\\n"; } if(this.txtE_A_AppName.Text.Trim().Length==0) { strErr+="所属应用名称不能为空!\\n"; } if(this.txtE_M_Name.Text.Trim().Length==0) { strErr+="PageCode模块名称与sy不能为空!\\n"; } if(this.txtE_M_PageCode.Text.Trim().Length==0) { strErr+="发生事件时模块名称不能为空!\\n"; } if(this.txtE_From.Text.Trim().Length==0) { strErr+="来源不能为空!\\n"; } if(!PageValidate.IsNumber(txtE_Type.Text)) { strErr+="日记类型,1:操作日记2:安全格式错误!\\n"; } if(this.txtE_IP.Text.Trim().Length==0) { strErr+="客户端IP地址不能为空!\\n"; } if(this.txtE_Record.Text.Trim().Length==0) { strErr+="详细描述不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int EventID=int.Parse(this.lblEventID.Text); string E_U_LoginName=this.txtE_U_LoginName.Text; int E_UserID=int.Parse(this.txtE_UserID.Text); DateTime E_DateTime=DateTime.Parse(this.txtE_DateTime.Text); int E_ApplicationID=int.Parse(this.txtE_ApplicationID.Text); string E_A_AppName=this.txtE_A_AppName.Text; string E_M_Name=this.txtE_M_Name.Text; string E_M_PageCode=this.txtE_M_PageCode.Text; string E_From=this.txtE_From.Text; int E_Type=int.Parse(this.txtE_Type.Text); string E_IP=this.txtE_IP.Text; string E_Record=this.txtE_Record.Text; Maticsoft.Model.sys_Event model=new Maticsoft.Model.sys_Event(); model.EventID=EventID; model.E_U_LoginName=E_U_LoginName; model.E_UserID=E_UserID; model.E_DateTime=E_DateTime; model.E_ApplicationID=E_ApplicationID; model.E_A_AppName=E_A_AppName; model.E_M_Name=E_M_Name; model.E_M_PageCode=E_M_PageCode; model.E_From=E_From; model.E_Type=E_Type; model.E_IP=E_IP; model.E_Record=E_Record; Maticsoft.BLL.sys_Event bll=new Maticsoft.BLL.sys_Event(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtE_U_LoginName.Text.Trim().Length == 0) { strErr += "用户名不能为空!\\n"; } if (!PageValidate.IsNumber(txtE_UserID.Text)) { strErr += "操作时用户ID与sys_Use格式错误!\\n"; } if (!PageValidate.IsDateTime(txtE_DateTime.Text)) { strErr += "事件发生的日期及时间格式错误!\\n"; } if (!PageValidate.IsNumber(txtE_ApplicationID.Text)) { strErr += "所属应用程序ID与sys_Ap格式错误!\\n"; } if (this.txtE_A_AppName.Text.Trim().Length == 0) { strErr += "所属应用名称不能为空!\\n"; } if (this.txtE_M_Name.Text.Trim().Length == 0) { strErr += "PageCode模块名称与sy不能为空!\\n"; } if (this.txtE_M_PageCode.Text.Trim().Length == 0) { strErr += "发生事件时模块名称不能为空!\\n"; } if (this.txtE_From.Text.Trim().Length == 0) { strErr += "来源不能为空!\\n"; } if (!PageValidate.IsNumber(txtE_Type.Text)) { strErr += "日记类型,1:操作日记2:安全格式错误!\\n"; } if (this.txtE_IP.Text.Trim().Length == 0) { strErr += "客户端IP地址不能为空!\\n"; } if (this.txtE_Record.Text.Trim().Length == 0) { strErr += "详细描述不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int EventID = int.Parse(this.lblEventID.Text); string E_U_LoginName = this.txtE_U_LoginName.Text; int E_UserID = int.Parse(this.txtE_UserID.Text); DateTime E_DateTime = DateTime.Parse(this.txtE_DateTime.Text); int E_ApplicationID = int.Parse(this.txtE_ApplicationID.Text); string E_A_AppName = this.txtE_A_AppName.Text; string E_M_Name = this.txtE_M_Name.Text; string E_M_PageCode = this.txtE_M_PageCode.Text; string E_From = this.txtE_From.Text; int E_Type = int.Parse(this.txtE_Type.Text); string E_IP = this.txtE_IP.Text; string E_Record = this.txtE_Record.Text; Maticsoft.Model.sys_Event model = new Maticsoft.Model.sys_Event(); model.EventID = EventID; model.E_U_LoginName = E_U_LoginName; model.E_UserID = E_UserID; model.E_DateTime = E_DateTime; model.E_ApplicationID = E_ApplicationID; model.E_A_AppName = E_A_AppName; model.E_M_Name = E_M_Name; model.E_M_PageCode = E_M_PageCode; model.E_From = E_From; model.E_Type = E_Type; model.E_IP = E_IP; model.E_Record = E_Record; Maticsoft.BLL.sys_Event bll = new Maticsoft.BLL.sys_Event(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }