/// <summary> /// 修改一个仓库 /// </summary> /// <param name="loggingSession">当前用户的登录信息</param> /// <param name="warehouse">仓库信息</param> /// <returns></returns> public bool ModifyWarehouse(LoggingSessionInfo loggingSession, WarehouseInfo warehouse) { //保存 int ret = 0; UnitWarehouseInfo unit_warehouse = new UnitWarehouseInfo(warehouse.Unit, warehouse); unit_warehouse.ID = this.NewGuid(); warehouse.ModifyUserID = loggingSession.CurrentUser.User_Id; warehouse.ModifyUserName = loggingSession.CurrentUser.User_Name; ISqlMapper sqlMapper = cSqlMapper.Instance(loggingSession.CurrentLoggingManager); try { sqlMapper.BeginTransaction(); //修改仓库 ret = sqlMapper.Update("Pos.Warehouse.Update", warehouse); //删除仓库与单位的旧关系 sqlMapper.Update("Pos.UnitWarehouse.DeleteByWarehouse", warehouse.ID); //添加仓库与单位的新关系 sqlMapper.Update("Pos.UnitWarehouse.Insert", unit_warehouse); sqlMapper.CommitTransaction(); } catch (Exception ex) { sqlMapper.RollBackTransaction(); throw ex; } cSqlMapper.Instance(loggingSession.CurrentLoggingManager).Update("Pos.Warehouse.Update", warehouse); return(ret == 1); }
public bool InsertWarehouse(LoggingManager loggingManager, WarehouseInfo warehouse) { if (string.IsNullOrEmpty(warehouse.ID)) { warehouse.ID = this.NewGuid(); } UnitWarehouseInfo unit_warehouse = new UnitWarehouseInfo(warehouse.Unit, warehouse); unit_warehouse.ID = this.NewGuid(); //保存 ISqlMapper sqlMapper = cSqlMapper.Instance(loggingManager); try { sqlMapper.BeginTransaction(); //添加仓库 sqlMapper.Insert("Pos.Warehouse.Insert", warehouse); //添加仓库与单位的关系 sqlMapper.Update("Pos.UnitWarehouse.Insert", unit_warehouse); sqlMapper.CommitTransaction(); } catch (Exception ex) { sqlMapper.RollBackTransaction(); throw ex; } return(true); }
public bool InsertWarehouse(LoggingManager loggingManager, WarehouseInfo warehouse, bool IsTran) { if (string.IsNullOrEmpty(warehouse.ID)) { warehouse.ID = this.NewGuid(); } UnitWarehouseInfo unit_warehouse = new UnitWarehouseInfo(warehouse.Unit, warehouse); unit_warehouse.ID = this.NewGuid(); //保存 try { //添加仓库 cSqlMapper.Instance(loggingManager).Insert("Pos.Warehouse.Insert", warehouse); //添加仓库与单位的关系 cSqlMapper.Instance(loggingManager).Update("Pos.UnitWarehouse.Insert", unit_warehouse); } catch (Exception ex) { throw ex; } return(true); }
public bool InsertWarehouse(WarehouseInfo warehouseInfo, UnitWarehouseInfo unitWarehouseInfo, out string strError, bool IsTran) { IDbTransaction tran = null; if (IsTran) { tran = this.SQLHelper.CreateTransaction(); } using (tran) { try { //1.判断重复 if (!IsExistWarehouseCode(warehouseInfo.wh_code, warehouseInfo.warehouse_id, tran)) { strError = "编码已经存在。"; //throw (new System.Exception(strError)); return(true); } //插入仓库 if (!SetWarehouseInsert(warehouseInfo, tran)) { strError = "插入仓库失败"; throw (new System.Exception(strError)); } //插入仓库 if (!SetUnitWarehouseInsert(unitWarehouseInfo, tran)) { strError = "插入仓库与门店关系失败"; throw (new System.Exception(strError)); } if (IsTran) { tran.Commit(); } strError = "成功"; return(true); } catch (Exception ex) { if (IsTran) { tran.Rollback(); } throw (ex); } } }
/// <summary> /// 修改一个仓库 /// </summary> /// <param name="loggingSession">当前用户的登录信息</param> /// <param name="warehouse">仓库信息</param> /// <returns></returns> public bool ModifyWarehouse(WarehouseInfo warehouse) { //保存 UnitWarehouseInfo unit_warehouse = new UnitWarehouseInfo(warehouse.Unit, warehouse); unit_warehouse.ID = this.NewGuid(); warehouse.ModifyUserID = loggingSessionInfo.CurrentUser.User_Id; warehouse.ModifyUserName = loggingSessionInfo.CurrentUser.User_Name; string strError = string.Empty; bool bReturn = posService.ModifyWarehouse(warehouse, unit_warehouse, out strError); return(bReturn); }
/// <summary> /// 仓库门店与仓库信息 /// </summary> /// <param name="unitWarehouseInfo"></param> /// <param name="pTran"></param> /// <returns></returns> public bool SetUnitWarehouseInsert(UnitWarehouseInfo unitWarehouseInfo, IDbTransaction pTran) { #region string sql = "insert into t_unit_warehouse(unit_warehouse_id, warehouse_id, unit_id) " + " values('" + unitWarehouseInfo.ID + "', '" + unitWarehouseInfo.Warehouse.warehouse_id + "', '" + unitWarehouseInfo.Unit.Id + "'); " + " update t_unit set if_flag='0' where unit_id= '" + unitWarehouseInfo.Unit.Id + "';"; #endregion if (pTran != null) { this.SQLHelper.ExecuteNonQuery((SqlTransaction)pTran, CommandType.Text, sql.ToString(), null); } else { this.SQLHelper.ExecuteNonQuery(sql); } return(true); }
/// <summary> /// 插入一个仓库 /// </summary> /// <param name="loggingSession">当前用户的登录信息</param> /// <param name="warehouse">仓库信息</param> /// <returns></returns> //public bool InsertWarehouse(LoggingSessionInfo loggingSession, WarehouseInfo warehouse) //{ // //if (string.IsNullOrEmpty(warehouse.ID)) // //{ // // warehouse.ID = this.NewGuid(); // //} // //warehouse.CreateUserID = loggingSession.CurrentUser.User_Id; // //warehouse.CreateUserName = loggingSession.CurrentUser.User_Name; // //UnitWarehouseInfo unit_warehouse = new UnitWarehouseInfo(warehouse.Unit, warehouse); // //unit_warehouse.ID = this.NewGuid(); // ////保存 // //ISqlMapper sqlMapper = cSqlMapper.Instance(loggingSession.CurrentLoggingManager); // //try // //{ // // sqlMapper.BeginTransaction(); // // //添加仓库 // // sqlMapper.Insert("Pos.Warehouse.Insert", warehouse); // // //添加仓库与单位的关系 // // sqlMapper.Update("Pos.UnitWarehouse.Insert", unit_warehouse); // // sqlMapper.CommitTransaction(); // //} // //catch (Exception ex) // //{ // // sqlMapper.RollBackTransaction(); // // throw ex; // //} // return true; //} //public bool InsertWarehouse(LoggingManager loggingManager, WarehouseInfo warehouse) //{ // //if (string.IsNullOrEmpty(warehouse.ID)) // //{ // // warehouse.ID = this.NewGuid(); // //} // //UnitWarehouseInfo unit_warehouse = new UnitWarehouseInfo(warehouse.Unit, warehouse); // //unit_warehouse.ID = this.NewGuid(); // ////保存 // //ISqlMapper sqlMapper = cSqlMapper.Instance(loggingManager); // //try // //{ // // sqlMapper.BeginTransaction(); // // //添加仓库 // // sqlMapper.Insert("Pos.Warehouse.Insert", warehouse); // // //添加仓库与单位的关系 // // sqlMapper.Update("Pos.UnitWarehouse.Insert", unit_warehouse); // // sqlMapper.CommitTransaction(); // //} // //catch (Exception ex) // //{ // // sqlMapper.RollBackTransaction(); // // throw ex; // //} // return true; //} /// <summary> /// 插入仓库信息 /// </summary> /// <param name="warehouse"></param> /// <returns></returns> public bool InsertWarehouse(WarehouseInfo warehouse, bool IsTran = true) { if (string.IsNullOrEmpty(warehouse.warehouse_id)) { warehouse.warehouse_id = this.NewGuid(); } UnitWarehouseInfo unit_warehouse = new UnitWarehouseInfo(warehouse.Unit, warehouse); unit_warehouse.ID = this.NewGuid(); string strError = string.Empty; bool b = posService.InsertWarehouse(warehouse, unit_warehouse, out strError, IsTran); if (!b) { throw (new System.Exception(strError)); } return(b); }
/// <summary> /// 修改仓库 /// </summary> /// <param name="warehouseInfo"></param> /// <param name="strError"></param> /// <returns></returns> public bool ModifyWarehouse(WarehouseInfo warehouseInfo, UnitWarehouseInfo unitWarehouseInfo, out string strError) { using (IDbTransaction tran = this.SQLHelper.CreateTransaction()) { try { //插入仓库与门店关系 if (!SetWarehouseModify(warehouseInfo, tran)) { strError = "修改仓库信息失败"; throw (new System.Exception(strError)); } //删除仓库与门店信息 if (!SetUnitWarehouseDelete(warehouseInfo.warehouse_id, tran)) { strError = "删除仓库信息失败"; throw (new System.Exception(strError)); } //插入仓库与门店关系 if (!SetUnitWarehouseInsert(unitWarehouseInfo, tran)) { strError = "插入仓库与门店关系失败"; throw (new System.Exception(strError)); } tran.Commit(); strError = "成功"; return(true); } catch (Exception ex) { tran.Rollback(); throw (ex); } } }