public static string GetTransaction(Guid TransactionTypeId, SqlTransaction tran) { string TransactionNo; bool isSaved = false; ECXWF.ECXEngine eng = new WarehouseApplication.ECXWF.ECXEngine(); eng.OpenTransaction(TransactionTypeId, UserBLL.GetCurrentUser(), new string[] { "" }, WarehouseBLL.GetWarehouseCode(UserBLL.GetCurrentWarehouse()), out TransactionNo); isSaved = WarehouseTrackingNoBLL.Save(TransactionNo, tran); if (isSaved == false) { WFTransaction.Remove(TransactionNo); throw new Exception("Unable to get Transaction.WFTransaction."); } else { return(TransactionNo); } }
/// <summary> /// A Method to insert Commodity Deposite request. /// </summary> /// <param name="transactionId"></param> /// <param name="clientId"></param> /// <param name="commodityId"></param> /// <param name="warehouseId"></param> /// <param name="reprsentativeId"></param> /// <param name="woredaId"></param> /// <param name="productionYear"></param> /// <param name="NumberOfBags"></param> /// <param name="dateTimeRecived"></param> /// <param name="weight"></param> /// <param name="remark"></param> /// <param name="status">Status of the CDR , 1- Apporved 0, Cancelled</param> /// <param name="createdBy">The user who created the Record </param> /// <returns>if Sucessfull returns True.</returns> public Nullable <Guid> AddCommodityDepositRequest(Guid TransactionTypeId) { // validate // 0-not saved Nullable <Guid> Id = null; SqlTransaction tran; SqlConnection conn = Connection.getConnection(); tran = conn.BeginTransaction(); CommodityDepositRequest ObjCommDepositeRequest = new CommodityDepositRequest(); string TransactionNo = String.Empty; int auditTrailStatus = -1; try { TransactionNo = WFTransaction.GetTransaction(TransactionTypeId, tran); if (string.IsNullOrEmpty(TransactionNo)) { throw new Exception("Unbale to Get Tracking No for Transaction Type " + TransactionTypeId); } this.TransactionId = TransactionNo; Id = ObjCommDepositeRequest.InsertCommodityDepositeRequest(this, tran); this.Id = (Guid)Id; if (Id != null) { AuditTrailBLL objAt = new AuditTrailBLL(); auditTrailStatus = objAt.saveAuditTrail(this, WFStepsName.AddArrival.ToString(), UserBLL.GetCurrentUser(), "Insert Arrival"); if (auditTrailStatus == -1) { if (TransactionNo != "") { WFTransaction.Remove(TransactionNo); } return(null); } else { HttpContext.Current.Session["TransactionNo"] = TransactionNo; tran.Commit(); return(Id); } } else { if (TransactionNo != "") { WFTransaction.Remove(TransactionNo); } tran.Rollback(); } } catch (Exception ex) { if (TransactionNo != "") { WFTransaction.Remove(TransactionNo); } tran.Rollback(); throw new Exception("TransactionNo -" + TransactionNo + "TransactionTypeId " + TransactionTypeId, ex); } finally { conn.Close(); tran.Dispose(); } return(Id); }