/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(SOperatDiaryData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into SOperatDiary("); strSql.Append("empId,functionId,recordId,operateContent,operateDt)"); strSql.Append(" values ("); strSql.Append("@empId,@functionId,@recordId,@operateContent,@operateDt)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@empId", SqlDbType.Int), new SqlParameter("@functionId", SqlDbType.NVarChar,20), new SqlParameter("@recordId", SqlDbType.NVarChar,20), new SqlParameter("@operateContent", SqlDbType.NVarChar,200), new SqlParameter("@operateDt", SqlDbType.DateTime) }; parameters[0].Value = model.empId; parameters[1].Value = model.functionId; parameters[2].Value = model.recordId; parameters[3].Value = model.operateContent; parameters[4].Value = model.operateDt == string.Empty ? null : model.operateDt; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
/// <summary> /// 更新一条"排托单"信息 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BArrangeBillData model) { bool ret = false; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransModify"); this.arrangeBillBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } this.arrangeBillBB.ModifyRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = model.id.ToString(); operatDiaryData.operateContent = "排托单修改一条id为“" + model.id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransModify"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "排托单修改记录“" + model.id.ToString() + "”时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return ret; }
/// <summary> /// 删除多条"排托单"信息 /// </summary> /// <param name="keyValues">主键值数组</param> public bool DeleteRecords(int[] keyValues) { bool ret = false; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransDelete"); this.arrangeBillBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } foreach (int key in keyValues) { this.arrangeBillBB.DeleteRecord(key); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = key.ToString(); operatDiaryData.operateContent = "排托单删除一条主键为“" + key.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); } if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransDelete"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "排托单删除多条记录时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } return ret; }
/// <summary> /// 增加一条"排托单"信息 /// </summary> /// <param name="model">model</param> public int AddRecord(BArrangeBillData model) { int id = 0; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransAdd"); this.arrangeBillBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } id = this.arrangeBillBB.AddRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = id.ToString(); operatDiaryData.operateContent = "排托单增加一条id为“" + id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransAdd"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "排托单增加记录时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return id; }
/// <summary> /// 删除一条"TSBarrivebill"信息 /// </summary> /// <param name="arriveBillNo">主键值</param> public bool DeleteRecord(string arriveBillNo) { bool ret = false; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransDelete"); this.sBarrivebillBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } this.sBarrivebillBB.DeleteRecord(arriveBillNo); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = arriveBillNo.ToString(); operatDiaryData.operateContent = "TSBarrivebill删除一条主键为“" + arriveBillNo.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransDelete"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "TSBarrivebill删除记录“" + arriveBillNo.ToString() + "”时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return ret; }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(SOperatDiaryData model) { return this.operatDiaryDB.ModifyRecord(model); }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(SOperatDiaryData model) { return this.operatDiaryDB.AddRecord(model); }
/// <summary> /// 记录操作日志 /// </summary> /// <param name="recordId">记录Id</param> /// <param name="logContent">操作内容</param> public void MakeOperatDiarylog(string recordId, string logContent) { SOperatDiaryData operatDiaryData = new SOperatDiaryData(); SOperatDiaryBB operatDiaryBB = new SOperatDiaryBB(); try { operatDiaryData.empId = this.currentUser.empId; operatDiaryData.functionId = this.itemNo; operatDiaryData.recordId = recordId; operatDiaryData.operateContent = logContent; operatDiaryData.operateDt = DateTime.Now.ToString(); operatDiaryBB.AddRecord(operatDiaryData); } finally { operatDiaryBB.Dispose(); } }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(SOperatDiaryData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update SOperatDiary set "); strSql.Append("empId=@empId,"); strSql.Append("functionId=@functionId,"); strSql.Append("recordId=@recordId,"); strSql.Append("operateContent=@operateContent,"); strSql.Append("operateDt=@operateDt"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@empId", SqlDbType.Int), new SqlParameter("@functionId", SqlDbType.NVarChar,20), new SqlParameter("@recordId", SqlDbType.NVarChar,20), new SqlParameter("@operateContent", SqlDbType.NVarChar,200), new SqlParameter("@operateDt", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.empId; parameters[2].Value = model.functionId; parameters[3].Value = model.recordId; parameters[4].Value = model.operateContent; parameters[5].Value = model.operateDt == string.Empty ? null : model.operateDt; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// �õ�һ��model /// </summary> /// <param name="id">����ֵ</param> /// <returns>model</returns> public SOperatDiaryData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from SOperatDiary"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; SOperatDiaryData model = new SOperatDiaryData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["id"] != DBNull.Value) { model.id = Convert.ToInt32(row["id"]); } if (row["empId"] != DBNull.Value) { model.empId = Convert.ToInt32(row["empId"]); } if (row["functionId"] != DBNull.Value) { model.functionId = Convert.ToString(row["functionId"]); } if (row["recordId"] != DBNull.Value) { model.recordId = Convert.ToString(row["recordId"]); } if (row["operateContent"] != DBNull.Value) { model.operateContent = Convert.ToString(row["operateContent"]); } if (row["operateDt"] != DBNull.Value) { model.operateDt = Convert.ToString(row["operateDt"]); } return model; } else { return null; } }