/// <summary> /// 修改 /// </summary> /// <param name="p_BE">要修改的实体</param> /// <param name="sqlTrans">事务类</param> public void RUpdate(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); GZNote entity = (GZNote)p_BE; GZNoteCtl control = new GZNoteCtl(sqlTrans); control.Update(entity); string sql = "DELETE Data_GZNoteDts WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); for (int i = 0; i < p_BE2.Length; i++) { GZNoteDtsRule rule = new GZNoteDtsRule(); GZNoteDts entityDts = (GZNoteDts)p_BE2[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; rule.RAdd(entityDts, sqlTrans); } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 检验字段值是否已存在 /// </summary> /// <param name="p_TableName">表名</param> /// <param name="p_FieldName">字段名</param> /// <param name="p_FieldValue">字段值</param> /// <param name="p_KeyField">主键(只考虑主键为ID的情况)</param> /// <param name="p_KeyValue">主键值</param> /// <param name="p_sqlTrans"></param> /// <returns></returns> private bool CheckFieldValueIsExist(BaseEntity p_BE, string p_FieldName, string p_FieldValue, IDBTransAccess p_sqlTrans) { GZNoteDts entity = (GZNoteDts)p_BE; bool ret = false; string sql = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, GZNoteDts.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID); DataTable dt = p_sqlTrans.Fill(sql); if (dt.Rows.Count != 0) { ret = true; } return(ret); }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); GZNoteDts entity = (GZNoteDts)p_BE; GZNoteDtsCtl control = new GZNoteDtsCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); GZNote entity = (GZNote)p_BE; GZNoteCtl control = new GZNoteCtl(sqlTrans); string sql = "SELECT FormNo FROM Data_GZNote WHERE FormNo=" + SysString.ToDBString(entity.FormNo); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("报告编号已存在,请重新生成"); } sql = "SELECT * FROM Data_GZNote WHERE FormDate=" + SysString.ToDBString(entity.FormDate); sql += " AND OPID=" + SysString.ToDBString(entity.OPID); dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("该时间的工作日报已存在,请检查"); } entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_GZNote, sqlTrans); control.AddNew(entity); for (int i = 0; i < p_BE2.Length; i++) { GZNoteDtsRule rule = new GZNoteDtsRule(); GZNoteDts entityDts = (GZNoteDts)p_BE2[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; rule.RAdd(entityDts, sqlTrans); } FormNoControlRule rulest = new FormNoControlRule(); rulest.RAddSort((int)FormNoControlEnum.日报编号, sqlTrans); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); GZNoteDts entity = (GZNoteDts)p_BE; GZNoteDtsCtl control = new GZNoteDtsCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_GZNoteDts, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private GZNoteDts[] EntityDtsGet() { int index = GetDataCompleteNum(); GZNoteDts[] entitydts = new GZNoteDts[index]; index = 0; for (int i = 0; i < gridView1.RowCount; i++) { if (CheckDataCompleteDts(i)) { entitydts[index] = new GZNoteDts(); entitydts[index].GZContext = SysConvert.ToString(gridView1.GetRowCellValue(i, "GZContext")); entitydts[index].HS = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "HS")); entitydts[index].Result = SysConvert.ToString(gridView1.GetRowCellValue(i, "Result")); entitydts[index].Remark = SysConvert.ToString(gridView1.GetRowCellValue(i, "Remark")); index++; } } return(entitydts); }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { GZNoteDts entity = (GZNoteDts)p_BE; }