/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { VendorFile MasterEntity = (VendorFile)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Data_VendorFile WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(Sql); } else { AffectedRows = sqlTrans.ExecuteNonQuery(Sql); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E); } }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); VendorFile entity = (VendorFile)p_BE; VendorFileCtl control = new VendorFileCtl(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, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); VendorFile entity = (VendorFile)p_BE; VendorFileCtl control = new VendorFileCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_VendorFile, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
private void btnPicSave_Click(object sender, EventArgs e) { if (HTDataID != 0) { if (SysConvert.ToInt32(drpPicNum.EditValue) == 0) { this.ShowMessage("请选择图片存放位置"); drpPicNum.Focus(); return; } VendorFileRule rule = new VendorFileRule(); VendorFile entity = GetSVendorFile(); rule.RSave(entity, HTDataID); this.ShowInfoMessage("图片存放成功"); BindPic(); } else { this.ShowMessage("请先保存基础资料"); return; } }
public void RSave(BaseEntity p_BE, int p_ID, IDBTransAccess sqlTrans) { try { VendorFile entity = (VendorFile)p_BE; string sql = "DELETE Data_VendorFile WHERE MainID=" + SysString.ToDBString(p_ID); sql += " AND Seq=" + SysString.ToDBString(entity.FileTypeID); sqlTrans.ExecuteNonQuery(sql); VendorFileRule rule = new VendorFileRule(); entity.MainID = p_ID; entity.Seq = entity.FileTypeID; rule.RAdd(entity, sqlTrans); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
public void RSave(BaseEntity[] p_BE, int p_ID, IDBTransAccess sqlTrans) { try { string sql = "DELETE Data_VendorFile WHERE MainID=" + SysString.ToDBString(p_ID); sqlTrans.ExecuteNonQuery(sql); for (int i = 0; i < p_BE.Length; i++) { VendorFileRule rule = new VendorFileRule(); VendorFile entity = (VendorFile)p_BE[i]; entity.MainID = p_ID; entity.Seq = i + 1; rule.RAdd(entity, sqlTrans); } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
private VendorFile GetSVendorFile() { VendorFile entity = new VendorFile(); int picNum = SysConvert.ToInt32(drpPicNum.EditValue); switch (picNum) { case 1: if (img1.Image != null) { entity.Context = TemplatePic.ImageToByte(img1.Image); entity.FileTypeID = picNum; entity.FileLength = SysConvert.ToDecimal(img1.Image.Width); entity.UploadOPID = FParamConfig.LoginID; entity.UploadTime = DateTime.Now.Date; entity.Remark = txtRemark1.Text.Trim(); } break; case 2: if (img2.Image != null) { entity.Context = TemplatePic.ImageToByte(img2.Image); entity.FileTypeID = picNum; entity.FileLength = SysConvert.ToDecimal(img2.Image.Width); entity.UploadOPID = FParamConfig.LoginID; entity.UploadTime = DateTime.Now.Date; entity.Remark = txtRemark2.Text.Trim(); } break; case 3: if (img3.Image != null) { entity.Context = TemplatePic.ImageToByte(img3.Image); entity.FileTypeID = picNum; entity.FileLength = SysConvert.ToDecimal(img3.Image.Width); entity.UploadOPID = FParamConfig.LoginID; entity.UploadTime = DateTime.Now.Date; entity.Remark = txtRemark3.Text.Trim(); } break; case 4: if (img4.Image != null) { entity.Context = TemplatePic.ImageToByte(img4.Image); entity.FileTypeID = picNum; entity.FileLength = SysConvert.ToDecimal(img4.Image.Width); entity.UploadOPID = FParamConfig.LoginID; entity.UploadTime = DateTime.Now.Date; entity.Remark = txtRemark4.Text.Trim(); } break; case 5: if (img5.Image != null) { entity.Context = TemplatePic.ImageToByte(img5.Image); entity.FileTypeID = picNum; entity.FileLength = SysConvert.ToDecimal(img5.Image.Width); entity.UploadOPID = FParamConfig.LoginID; entity.UploadTime = DateTime.Now.Date; entity.Remark = txtRemark5.Text.Trim(); } break; default: break; } return(entity); }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { VendorFile entity = (VendorFile)p_BE; }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { VendorFile MasterEntity = (VendorFile)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Data_VendorFile("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("MainID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MainID) + ","); MasterField.Append("Seq" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Seq) + ","); MasterField.Append("FileTypeID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FileTypeID) + ","); MasterField.Append("Context" + ","); MasterValue.Append(@"@Context" + ","); MasterField.Append("FileName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FileName) + ","); MasterField.Append("FileExec" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FileExec) + ","); MasterField.Append("FileLength" + ","); if (MasterEntity.FileLength != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.FileLength) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("UploadTime" + ","); if (MasterEntity.UploadTime != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.UploadTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("UploadOPID" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.UploadOPID) + ")"); object[,] obja = new object[2, 1]; obja[0, 0] = "@Context"; obja[1, 0] = MasterEntity.Context; //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString(), obja); } else { AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString(), obja); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E); } }
/// <summary> /// 修改 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { VendorFile MasterEntity = (VendorFile)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Data_VendorFile SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ","); UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ","); UpdateBuilder.Append(" FileTypeID=" + SysString.ToDBString(MasterEntity.FileTypeID) + ","); UpdateBuilder.Append(" Context=@Context" + ","); UpdateBuilder.Append(" FileName=" + SysString.ToDBString(MasterEntity.FileName) + ","); UpdateBuilder.Append(" FileExec=" + SysString.ToDBString(MasterEntity.FileExec) + ","); if (MasterEntity.FileLength != 0) { UpdateBuilder.Append(" FileLength=" + SysString.ToDBString(MasterEntity.FileLength) + ","); } else { UpdateBuilder.Append(" FileLength=null,"); } UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); if (MasterEntity.UploadTime != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" UploadTime=" + SysString.ToDBString(MasterEntity.UploadTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" UploadTime=null,"); } UpdateBuilder.Append(" UploadOPID=" + SysString.ToDBString(MasterEntity.UploadOPID)); UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID)); object[,] obja = new object[2, 1]; obja[0, 0] = "@Context"; obja[1, 0] = MasterEntity.Context; //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString(), obja); } else { AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString(), obja); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E); } }