/// <summary> /// The passed data source should not have an already existing transaction because /// we create our own transaction. /// </summary> /// <param name="pickslipId"></param> /// <param name="ds"></param> public static void DeleteBoxesForPickslipGroup(int pickslipId, OracleDataSource ds) { const string QUERY_BOX = @" delete from <proxy />box b where b.ia_id is null and b.pickslip_id = :pickslip_id "; const string QUERY_BOXDET = @" delete from <proxy />boxdet bd where bd.ucc128_id in( select b.ucc128_id from <proxy />box b where b.ia_id is null and b.pickslip_id = :pickslip_id ) "; ds.DeleteParameters.Clear(); ds.DeleteParameters.Add("pickslip_id", DbType.Int32, pickslipId.ToString()); ds.SysContext.ModuleName = "BoxCreator.DeleteBoxes"; try { ds.BeginTransaction(); ds.DeleteSql = QUERY_BOXDET; int i = ds.Delete(); ds.DeleteSql = QUERY_BOX; i = ds.Delete(); ds.CommitTransaction(); } catch (Exception) { ds.RollBackTransaction(); throw; } }
/// <summary> /// This function will insert the created boxes of this pickslip group in database by using the box object. /// It is managing the transaction so that all boxes of a pickslip will be created or none. /// </summary> /// <param name="ds"></param> internal void InsertBoxesInDb(OracleDataSource ds) { int seq = this.SequenceInPs; //selecting the distinct pickslips to set the picking status var q1 = (from ps in this._skuList select ps.PickslipId).Distinct(); ds.BeginTransaction(); try { foreach (Box box in this.Boxes) { ++seq; box.InsertInDb(ds, this.VwhId, seq, this.PickslipPrefix); } //Setting the picking status for the pickslips for which we have created the box foreach (var ps in q1) { this.SetPickslipStatus(ds, Convert.ToInt32(ps)); } ds.CommitTransaction(); } catch (Exception) { ds.RollBackTransaction(); throw; } }