/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { ItemGBUPHis MasterEntity = (ItemGBUPHis)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Data_ItemGBUPHis 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_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { ItemGBUPHis MasterEntity = (ItemGBUPHis)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Data_ItemGBUPHis SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" GBCode=" + SysString.ToDBString(MasterEntity.GBCode) + ","); UpdateBuilder.Append(" GBStatusIDS=" + SysString.ToDBString(MasterEntity.GBStatusIDS) + ","); UpdateBuilder.Append(" GBStatusIDE=" + SysString.ToDBString(MasterEntity.GBStatusIDE) + ","); if (MasterEntity.GDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" GDate=" + SysString.ToDBString(MasterEntity.GDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" GDate=null,"); } UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" UpOPID=" + SysString.ToDBString(MasterEntity.UpOPID)); UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID)); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E); } }
private ItemGBUPHis GetEntity() { ItemGBUPHis entity = new ItemGBUPHis(); entity.GBCode = txtGBCode.Text.Trim(); entity.GBStatusIDS = SysConvert.ToInt32(drpGBStatusID2.EditValue); entity.GBStatusIDE = SysConvert.ToInt32(drpGBStatusID.EditValue); entity.GDate = DateTime.Now.Date; entity.UpOPID = FParamConfig.LoginID; return(entity); }
/// <summary> /// 修改挂板状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click_1(object sender, EventArgs e) { try { if (txtGBCode.Text.Trim() == "") { this.ShowMessage("请扫描挂板条码"); txtGBCode.Focus(); return; } if (SysConvert.ToInt32(drpGBStatusID.EditValue) == 0) { this.ShowMessage("请选择修改后的挂板状态"); drpGBStatusID.Focus(); return; } if (SysConvert.ToInt32(drpGBStatusID2.EditValue) == 0) { this.ShowMessage("请选择修改前的挂板状态"); drpGBStatusID2.Focus(); return; } if (SysConvert.ToInt32(drpGBStatusID.EditValue) == SysConvert.ToInt32(drpGBStatusID2.EditValue)) { this.ShowMessage("修改前与修改后挂板状态相同,请重新选择修改后挂板状态"); drpGBStatusID.Focus(); return; } ItemGBUPHisRule rule = new ItemGBUPHisRule(); ItemGBUPHis entity = GetEntity(); rule.RAdd(entity); string sql = "UPDATE Data_ItemGB SET GBStatusID=" + SysString.ToDBString(entity.GBStatusIDE); sql += " WHERE GBCode=" + SysString.ToDBString(txtGBCode.Text.Trim()); SysUtils.ExecuteNonQuery(sql); Bind(); txtGBCode.Text = ""; drpGBStatusID.EditValue = 0; drpGBStatusID2.EditValue = 0; } catch (Exception E) { this.ShowMessage(E.Message); } }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); ItemGBUPHis entity = (ItemGBUPHis)p_BE; ItemGBUPHisCtl control = new ItemGBUPHisCtl(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); ItemGBUPHis entity = (ItemGBUPHis)p_BE; ItemGBUPHisCtl control = new ItemGBUPHisCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_ItemGBUPHis, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { ItemGBUPHis MasterEntity = (ItemGBUPHis)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Data_ItemGBUPHis("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("GBCode" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.GBCode) + ","); MasterField.Append("GBStatusIDS" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.GBStatusIDS) + ","); MasterField.Append("GBStatusIDE" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.GBStatusIDE) + ","); MasterField.Append("GDate" + ","); if (MasterEntity.GDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.GDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("UpOPID" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.UpOPID) + ")"); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } 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_BE"></param> private void CheckCorrect(BaseEntity p_BE) { ItemGBUPHis entity = (ItemGBUPHis)p_BE; }