/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); SBit entity = (SBit)p_BE; SBitCtl control = new SBitCtl(sqlTrans); //entity.ID=EntityIDTable.GetID((long)SysEntity.WH_SBit,sqlTrans); string sql = "SELECT SBitID FROM WH_SBit WHERE SBitID=" + SysString.ToDBString(entity.SBitID) + " AND SectionID=" + SysString.ToDBString(entity.SectionID) + " AND WHID=" + SysString.ToDBString(entity.WHID); DataTable dt = SysUtils.Fill(sql); if (dt.Rows.Count != 0) { throw new Exception("该仓库位编码已经存在,请重新输入"); } FormNoControlRule rule = new FormNoControlRule(); entity.SBitISN = rule.RGetFormNo(1026, 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 Delete(BaseEntity p_Entity) { try { SBit MasterEntity = (SBit)p_Entity; if (MasterEntity.SBitID == "") { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM WH_SBit WHERE " + "SBitID=" + SysString.ToDBString(MasterEntity.SBitID); //执行 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 RUpdate(BaseEntity p_BE, string p_Old, IDBTransAccess sqlTrans) { try { string sql = "SELECT * FROM WH_IOFormDts WHERE SBitID =" + SysString.ToDBString(p_Old); if (sqlTrans.Fill(sql).Rows.Count > 0) { throw new Exception("该仓位已经做出入库单据,不能修改"); return; } this.CheckCorrect(p_BE); SBit entity = (SBit)p_BE; //SBitCtl control = new SBitCtl(sqlTrans); //string sql = "SELECT SBitID FROM WH_SBit WHERE SBitID=" + SysString.ToDBString(entity.SBitID) +" AND SectionID=" + SysString.ToDBString(entity.SectionID) + " AND WHID=" + SysString.ToDBString(entity.WHID); //sql+=" AND SBitID<>"+SysString.ToDBString(entity.OldSBitID); //DataTable dt = sqlTrans.Fill(sql); //if(dt.Rows.Count!=0) //{ // throw new Exception("该仓库位编码已经存在,请重新输入"); //} this.Update(entity, p_Old, 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 RUpdate(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); SBit entity = (SBit)p_BE; SBitCtl control = new SBitCtl(sqlTrans); //string sql = "SELECT SBitID FROM WH_SBit WHERE SBitID=" + SysString.ToDBString(entity.SBitID) +" AND SectionID=" + SysString.ToDBString(entity.SectionID) + " AND WHID=" + SysString.ToDBString(entity.WHID); //sql+=" AND SBitID<>"+SysString.ToDBString(entity.OldSBitID); //DataTable dt = sqlTrans.Fill(sql); //if(dt.Rows.Count!=0) //{ // throw new Exception("该仓库位编码已经存在,请重新输入"); //} control.Update(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private SBit GetEntitySBit() { SBit entity = new SBit(); entity.SBitID = SysConvert.ToString(gridView3.GetFocusedRowCellValue("SBitID")); entity.SelectByID(); entity.MainID = HTDataID; entity.SBitID = txtSBit.Text.Trim(); entity.SectionID = SysConvert.ToString(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "SectionID")); entity.WHID = txtWHIDBit.Text.Trim(); entity.IsUseable = SysConvert.ToInt32(drpIsUseableBit.EditValue); entity.Remark = txtRemarkBit.Text.Trim(); return(entity); }
/// <summary> /// 删除位 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeleteBit_Click(object sender, EventArgs e) { try { if (txtSBit.Text.Trim() == "") { this.ShowMessage("请选择要删除的记录"); return; } if (DialogResult.Yes != this.ShowConfirmMessage("确定要删除本记录?")) { return; } SBitRule rule = new SBitRule(); SBit entity = new SBit(); entity.MainID = HTDataID; entity.WHID = txtWHID.Text.Trim(); entity.SectionID = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "SectionID").ToString(); entity.SBitID = txtSBit.Text.Trim(); //entity.OldSBitID = txtSBit.Text.Trim(); rule.RDelete(entity); FCommon.AddDBLog(this.Text, "位删除", "ID:" + entity.SBitID, ""); string tempwhid = entity.WHID; BindGridSBit(); ProcessGrid.GridViewFocus(gridView1, new string[1] { "SectionID" }, new string[1] { entity.WHID }); ProcessGrid.GridViewFocus(gridView3, new string[1] { "SBitID" }, new string[1] { entity.SectionID }); // GridViewFocus(gridView3,new string[1]{"SBitID"},new string[1]{entity.SBitID}); // Common.AddDBLog(this.Text,OPType.删除,"ID:"+entity.OldSBitID.ToString(),"位"); } 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); SBit entity = (SBit)p_BE; SBitCtl control = new SBitCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 更新位 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdateBit_Click(object sender, EventArgs e) { try { if (txtSBit.Text.Trim() == "") { this.ShowMessage("请选择要修改的记录"); return; } if (!CheckCorrectBit()) { return; } SBitRule rule = new SBitRule(); SBit entity = this.GetEntitySBit(); string OLDSBitID = SysConvert.ToString(gridView3.GetFocusedRowCellValue("SBitID")); //entity.MainID = HTDataID; //entity.WHID = txtWHID.Text.Trim(); //entity.SectionID = txtSectionIDBit.Text.Trim(); //entity.SBitID = txtSBit.Text.Trim(); rule.RUpdate(entity, OLDSBitID); FCommon.AddDBLog(this.Text, "位更新", "ID:" + entity.SBitID, "New ID:" + entity.SBitID); BindGridSBit(); //ProcessGrid.GridViewFocus(gridView1, new string[1] { "WHID" }, new string[1] { entity.WHID }); ProcessGrid.GridViewFocus(gridView1, new string[1] { "SectionID" }, new string[1] { entity.SectionID }); ProcessGrid.GridViewFocus(gridView3, new string[1] { "SBitID" }, new string[1] { entity.SBitID }); // Common.AddDBLog(this.Text,OPType.更新,"ID:"+entity.OldSBitID.ToString(),"位"); } catch (Exception E) { this.ShowMessage(E.Message); } }
/// <summary> /// 新增位 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnInsertBit_Click(object sender, EventArgs e) { try { if (!CheckCorrectBit()) { return; } SBitRule rule = new SBitRule(); SBit entity = this.GetEntitySBit(); if (SysConvert.ToInt32(drpWHPosMethodID.EditValue) == 1 || SysConvert.ToInt32(drpWHPosMethodID.EditValue) == 2) { this.ShowMessage("物理位置不包含位无法新增"); return; } else { rule.RAdd(entity); } FCommon.AddDBLog(this.Text, "位新增", "ID:" + entity.SBitID, ""); BindGridSBit(); // ProcessGrid.GridViewFocus(gridView1, new string[1] { "WHID" }, new string[1] { entity.WHID }); ProcessGrid.GridViewFocus(gridView1, new string[1] { "SectionID" }, new string[1] { entity.SectionID }); ProcessGrid.GridViewFocus(gridView3, new string[1] { "SBitID" }, new string[1] { entity.SBitID }); // Common.AddDBLog(this.Text,OPType.新增,"ID:"+entity.SBitID.ToString(),"位"); } catch (Exception E) { this.ShowMessage(E.Message); } }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { SBit MasterEntity = (SBit)p_Entity; if (MasterEntity.SBitID == "") { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO WH_SBit("); MasterValue.Append(" VALUES("); MasterField.Append("MainID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MainID) + ","); MasterField.Append("Seq" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Seq) + ","); MasterField.Append("SubSeq" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SubSeq) + ","); MasterField.Append("WHID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.WHID) + ","); MasterField.Append("SectionID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SectionID) + ","); MasterField.Append("SBitID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SBitID) + ","); MasterField.Append("IsUseable" + ","); if (MasterEntity.IsUseable != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.IsUseable) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("WeightMax" + ","); if (MasterEntity.WeightMax != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.WeightMax) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("BulkMax" + ","); if (MasterEntity.BulkMax != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.BulkMax) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("SBitISN" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.SBitISN) + ")"); //执行 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_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { SBit MasterEntity = (SBit)p_Entity; if (MasterEntity.SBitID == "") { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE WH_SBit SET "); UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ","); UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ","); UpdateBuilder.Append(" SubSeq=" + SysString.ToDBString(MasterEntity.SubSeq) + ","); UpdateBuilder.Append(" WHID=" + SysString.ToDBString(MasterEntity.WHID) + ","); UpdateBuilder.Append(" SectionID=" + SysString.ToDBString(MasterEntity.SectionID) + ","); UpdateBuilder.Append(" SBitID=" + SysString.ToDBString(MasterEntity.SBitID) + ","); if (MasterEntity.IsUseable != 0) { UpdateBuilder.Append(" IsUseable=" + SysString.ToDBString(MasterEntity.IsUseable) + ","); } else { UpdateBuilder.Append(" IsUseable=null,"); } if (MasterEntity.WeightMax != 0) { UpdateBuilder.Append(" WeightMax=" + SysString.ToDBString(MasterEntity.WeightMax) + ","); } else { UpdateBuilder.Append(" WeightMax=null,"); } if (MasterEntity.BulkMax != 0) { UpdateBuilder.Append(" BulkMax=" + SysString.ToDBString(MasterEntity.BulkMax) + ","); } else { UpdateBuilder.Append(" BulkMax=null,"); } UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" SBitISN=" + SysString.ToDBString(MasterEntity.SBitISN)); UpdateBuilder.Append(" WHERE " + "SBitID=" + SysString.ToDBString(MasterEntity.SBitID)); //执行 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); } }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { SBit entity = (SBit)p_BE; }