private void RemoveTransaction(List <string> list) { foreach (string s in list) { WFTransaction.Close(s); } }
public bool Add() { bool isSaved = false; SqlConnection conn = new SqlConnection(); SqlTransaction tran; conn = Connection.getConnection(); tran = conn.BeginTransaction(); try { string TrackingNo = ""; TrackingNo = WFTransaction.GetTransaction("WHEditAppGRN", tran); this.TrackingNo = TrackingNo; this.Id = Guid.NewGuid(); isSaved = RequestforEditGRNDAL.save(tran, this); if (isSaved == true) { int At = -1; AuditTrailBLL objAt = new AuditTrailBLL(); At = objAt.saveAuditTrail(this, WFStepsName.RequestforEditGRN.ToString(), UserBLL.GetCurrentUser(), "Add Approved GRN Edit"); if (At == 1) { tran.Commit(); } else { tran.Rollback(); } } else { if (TrackingNo != "") { WFTransaction.Close(TrackingNo); } tran.Rollback(); } } catch (Exception ex) { tran.Rollback(); throw new Exception("Unable to Add New record", ex); } finally { tran.Dispose(); if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Dispose(); } return(isSaved); }
public bool Update() { bool isSaved = false; SqlConnection conn = null; SqlTransaction tran = null; RequestforEditGRNBLL objEdit = new RequestforEditGRNBLL(); objEdit = objEdit.GetById(Id); AuditTrailBLL objAt = new AuditTrailBLL(); try { conn = Connection.getConnection(); tran = conn.BeginTransaction(); isSaved = RequestforEditGRNDAL.Update(tran, this); if (isSaved == true) { string AppMode = WFStepsName.EditAppGRN.ToString(); if (objAt.saveAuditTrail(objEdit, this, AppMode, UserBLL.GetCurrentUser(), "Update-ApprovedGRNCancelRequest") == 1) { if (objEdit.Status == RequestforEditGRNStatus.New && this.Status == RequestforEditGRNStatus.Approved) { WFTransaction.WorkFlowManager(this.TrackingNo); } else if (objEdit.Status == RequestforEditGRNStatus.New && this.Status == RequestforEditGRNStatus.Approved) { WFTransaction.Close(this.TrackingNo); } tran.Commit(); return(true); } else { tran.Rollback(); return(false); } } else { tran.Rollback(); return(false); } } catch (Exception ex) { tran.Rollback(); throw new Exception("Unable to update Data.", ex); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } if (tran != null) { tran.Dispose(); } } }
public bool AllowGRNEdit(RequestforEditGRNStatus oldStatus, RequestforEditGRNBLL old) { //Update Status accordingly. //Set GRN Status to On Edit bool isSaved = false; SqlConnection conn = null; SqlTransaction tran = null; try { conn = Connection.getConnection(); tran = conn.BeginTransaction(); isSaved = RequestforEditGRNDAL.Update(tran, this); isSaved = GRNDAL.UpdateGRNStatus(this.GRN_Number, GRNStatus.OpenForEdit, tran); if (this.Status == RequestforEditGRNStatus.Approved && oldStatus == RequestforEditGRNStatus.Approved) { // Update GRN Status to OpenForEdit if (isSaved == true) { int at = -1; AuditTrailBLL objat = new AuditTrailBLL(); at = objat.saveAuditTrail(old, this, WFStepsName.RequestforEditGRN.ToString(), UserBLL.GetCurrentUser(), "Open GRN for Edit"); if (at == 1) { WFTransaction.WorkFlowManager(this.TrackingNo); tran.Commit(); } else { tran.Rollback(); isSaved = false; } } else { isSaved = false; tran.Rollback(); } } else if (this.Status == RequestforEditGRNStatus.Cancelled) { WFTransaction.Close(this.TrackingNo); isSaved = true; } } catch (Exception ex) { tran.Rollback(); throw new Exception("Unable to update Data.", ex); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } if (tran != null) { tran.Dispose(); } } return(isSaved); }
public Boolean UpdateManagerApproval(SamplingResultBLL oldObj) { // TODO : Check Sampling is Completed - check if Code is generated. bool isSaved = false; SqlTransaction tran = null; SqlConnection conn = null; AuditTrailBLL objat = new AuditTrailBLL(); int at = -1; try { conn = Connection.getConnection(); tran = conn.BeginTransaction(); this.LastModifiedBy = UserBLL.GetCurrentUser(); isSaved = SamplingResultDAL.UpdateManagerApproval(this, tran); if (isSaved == true) { if (oldObj == null) { throw new Exception("Invalid Old object-UpdateManagerApproval Method."); } string strOld = "(Id-" + oldObj.Id.ToString() + ")," + "(Status-" + oldObj.Status.ToString() + "),(LastModifiedBy-" + oldObj.LastModifiedBy.ToString() + ")"; string strNew = "(Id-" + this.Id.ToString() + ")," + "(Status-" + this.Status.ToString() + "),(LastModifiedBy-" + this.LastModifiedBy.ToString() + ")"; strNew += "(ManagerApprovalRemark-" + this.ManagerApprovalRemark + "),(LastModifiedTimestamp-" + this.LastModifiedTimestamp.ToString() + ")"; at = objat.saveAuditTrailStringFormat(strOld, strNew, WFStepsName.EditSamplingResult.ToString(), UserBLL.GetCurrentUser(), "Edit Sampling Result"); if (at == 1) { if ((oldObj.Status == SamplingResultStatus.New) && (this.Status == SamplingResultStatus.Approved)) { ECXWF.CMessage mess = WFTransaction.Request(this.TrackingNo); HttpContext.Current.Session["msg"] = mess; if (mess.Name.Trim().ToUpper() == "AddSamplingResult".ToUpper()) { WFTransaction.WorkFlowManager(this.TrackingNo); } else { throw new Exception("The Task has already been done."); } } else if ((oldObj.Status == SamplingResultStatus.New) && (this.Status == SamplingResultStatus.Cancelled)) { ECXWF.CMessage mess = WFTransaction.Request(this.TrackingNo); HttpContext.Current.Session["msg"] = mess; if (mess.Name.Trim().ToUpper() == "AddSamplingResult".ToUpper()) { WFTransaction.Close(this.TrackingNo); } else { throw new Exception("The Task has already been done."); } } } else { objat.RoleBack(); tran.Rollback(); isSaved = false; } if (at == 1) { tran.Commit(); } else { isSaved = false; tran.Rollback(); } } return(isSaved); } catch (Exception ex) { if (at == 1) { objat.RoleBack(); } tran.Rollback(); throw ex; } finally { tran.Dispose(); conn.Close(); } }
public Boolean Add(List <SamplingResultBLL> list, Guid SamplingId) { if (list == null) { throw new Exception("No sampling Result to save."); } SamplingBLL objSampling = new SamplingBLL(); objSampling = objSampling.GetSampleDetail(SamplingId); if (objSampling == null) { throw new Exception("Invalid Tracking No.Plase Tray Again."); } if (String.IsNullOrEmpty(objSampling.TrackingNo) == true) { throw new Exception("Invalid Tracking No.Plase Tray Again."); } string OldTrackingNo = String.Empty; int count = 0; count = list.Count; bool isSaved = false; SqlTransaction tran = null; SqlConnection conn = null; List <string> tranlist = new List <string>(); try { conn = Connection.getConnection(); tran = conn.BeginTransaction(); foreach (SamplingResultBLL i in list) { if (count == 1) { i.Id = Guid.NewGuid(); i.TrackingNo = objSampling.TrackingNo; i.ResultReceivedDateTime = this.ResultReceivedDateTime; i.IsPlompOk = this.IsPlompOk; if (this.IsPlompOk == true) { i.Status = SamplingResultStatus.Approved; } else { i.Status = SamplingResultStatus.New; } isSaved = SamplingResultDAL.InsertSamplingResult(i, tran); int at = -1; if (isSaved == true) { AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrail(i, WFStepsName.AddSamplingResult.ToString(), UserBLL.GetCurrentUser(), "Add Sampling Result"); if (at == 1) { if (i.Status == SamplingResultStatus.Approved) { WFTransaction.WorkFlowManager(objSampling.TrackingNo); } } else { tran.Rollback(); isSaved = false; } } } else if (count > 1) { //Close previous Tracking No. OldTrackingNo = objSampling.TrackingNo; Guid TransactionTypeId = Guid.Empty; i.ResultReceivedDateTime = this.ResultReceivedDateTime; try { TransactionTypeId = TransactionTypeProvider.GetTransactionTypeId("RegularCoffeeMixed"); } catch (InvalidTransactionType ex) { throw new Exception("Can Not open Mixed Transaction Type please Contact the Administrator.", ex); } string tranNo = WFTransaction.GetTransaction(TransactionTypeId, tran); if (string.IsNullOrEmpty(tranNo) == true) { throw new Exception("Can Not get Transaction Number please Contact the Administrator."); } else { i.Id = Guid.NewGuid(); i.TrackingNo = tranNo; i.IsPlompOk = this.IsPlompOk; i.ResultReceivedDateTime = this.ResultReceivedDateTime; tranlist.Add(tranNo); isSaved = SamplingResultDAL.InsertSamplingResult(i, tran); int at = -1; if (i.IsPlompOk == true) { i.Status = SamplingResultStatus.Approved; } else { i.Status = SamplingResultStatus.New; } if (i.Status == SamplingResultStatus.Approved) { //Move One Step ECXWF.CMessage mess = null; mess = WFTransaction.Request(tranNo); if (mess == null) { throw new Exception("Can Not get Message for the Tracking No."); } else { if (WFStepName.AddSamplingResult.ToString().Trim().ToUpper() == mess.Name.Trim().ToUpper()) { WFTransaction.WorkFlowManager(tranNo, mess); } else { throw new Exception("Can Not get Message for the Tracking No."); } } } AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrail(i, WFStepsName.AddSamplingResult.ToString(), UserBLL.GetCurrentUser(), "Add Sampling Result"); if (at == -1) { isSaved = false; break; } if (isSaved == false) { break; } } } } if (string.IsNullOrEmpty(OldTrackingNo) != true) { if ((isSaved == true) && (list.Count > 0)) { WFTransaction.Close(OldTrackingNo); } } if (isSaved == true) { tran.Commit(); return(true); } else { tran.Rollback(); return(false); } } catch (Exception ex) { RemoveTransaction(tranlist); tran.Rollback(); throw ex; } finally { if (tran != null) { tran.Dispose(); } if (conn.State == ConnectionState.Open) { conn.Close(); } } }
public bool ClientAcceptance(Guid Id, int Status, GradingResultStatus GradeRecivedStatatus, Nullable <DateTime> ClientAccpetedTimeStamp, out string strQueueNo) { DateTime dt; GradingResultBLL objUpdate = new GradingResultBLL(); objUpdate.ID = Id; objUpdate.Status = (GradingResultStatus)Status; try { dt = (DateTime)ClientAccpetedTimeStamp; } catch { throw new Exception("Invalid Client Acceptance Date."); } objUpdate.ClientAcceptanceTimeStamp = ClientAccpetedTimeStamp; // Get Queue No. DateTime currDate = DateTime.Today; Guid WarehouseId = UserBLL.GetCurrentWarehouse(); string Code = currDate.Day.ToString() + currDate.Year.ToString().Substring(2, 2); int? QueueNo = null; int? PreWeightQueueNo = null; try { GradingResultDAL.GetQueueNumber(Code, WarehouseId, currDate, out QueueNo, out PreWeightQueueNo); if (QueueNo == null || PreWeightQueueNo == null) { throw new Exception("Can not get queue number"); } } catch { new Exception("Can not get queue number."); } objUpdate.QueueDate = currDate; objUpdate.QueueNo = (int)QueueNo; strQueueNo = PreWeightQueueNo.ToString(); objUpdate.PreWeightQueueNo = (int)PreWeightQueueNo; bool isSaved = false; SqlTransaction tran; SqlConnection conn = Connection.getConnection(); tran = conn.BeginTransaction(); GradingResultBLL objGradingResult = new GradingResultBLL(); objGradingResult = objGradingResult.GetGradingResultById(Id, tran); AuditTrailBLL objAt = new AuditTrailBLL(); int At = -1; try { isSaved = GradingResultDAL.ClientAcceptanceGradingResult(objUpdate, tran); if (objAt.saveAuditTrail(objGradingResult, objUpdate, WFStepsName.ClientAcceptance.ToString(), UserBLL.GetCurrentUser(), "Grading Result Client Respose") == 1) { isSaved = true; At = 1; } string TranNo; TranNo = objGradingResult.TrackingNo; if (string.IsNullOrEmpty(TranNo) == true) { tran.Rollback(); if (At == 1) { objAt.RoleBack(); } isSaved = false; } else { if ((int)GradingResultStatus.ClientAccepted == Status && (GradeRecivedStatatus == GradingResultStatus.New || GradeRecivedStatatus == GradingResultStatus.Approved)) { WFTransaction.WorkFlowManager(TranNo); HttpContext.Current.Session["CATranNo"] = TranNo; } else { WFTransaction.Close(TranNo); //Create a new Grading Dispute task or General reqiurment fail. } } if (isSaved == true) { tran.Commit(); return(true); } else { tran.Rollback(); objAt.RoleBack(); HttpContext.Current.Session["CATranNo"] = null; return(false); } } catch (Exception ex) { tran.Rollback(); if (At == 1) { objAt.RoleBack(); } throw ex; } finally { tran.Dispose(); conn.Close(); } }
public bool Update() { bool isSaved = false; SqlTransaction trans; SqlConnection conn = new SqlConnection(); conn = Connection.getConnection(); trans = conn.BeginTransaction(); ReSamplingBLL objold = new ReSamplingBLL(); objold = objold.GetById(this.Id); if (objold == null) { throw new Exception("Invalid Old Value exception"); } try { isSaved = ReSamplingDAL.Update(this, trans); if (isSaved == true) { int at = -1; AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrail(objold, this, WFStepsName.EditResampling.ToString(), UserBLL.GetCurrentUser(), "Update Resampling"); if (at == 1) { if (this.Status == ReSamplingStatus.Approved) { WFTransaction.WorkFlowManager(this.TrackingNo); } else if (this.Status == ReSamplingStatus.Cancelled) { WFTransaction.Close(this.TrackingNo); } trans.Commit(); return(true); } else { trans.Commit(); return(false); } } else { trans.Rollback(); return(false); } } catch (Exception ex) { trans.Rollback(); throw new Exception("Unable to Update Data", ex); } finally { trans.Dispose(); if (conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } }
public bool Add() { int At = -1; bool isSaved = false; SqlConnection conn = new SqlConnection(); SqlTransaction tran; conn = Connection.getConnection(); tran = conn.BeginTransaction(); AuditTrailBLL objAt = new AuditTrailBLL(); try { string TrackingNo = ""; TrackingNo = WFTransaction.GetTransaction("ApprovedGRNCancel", tran); this.Id = Guid.NewGuid(); this.TrackingNo = TrackingNo; this.CreatedBy = UserBLL.GetCurrentUser(); this.CreatedTimestamp = DateTime.Now; isSaved = RequestforApprovedGRNCancelationDAL.save(tran, this); isSaved = WarehouseRecieptBLL.RequestCancel(this.GRNId, TrackingNo, this.Remark); if (isSaved == true) { At = objAt.saveAuditTrail(this, WFStepsName.CancelGRN.ToString(), UserBLL.GetCurrentUser(), "Add Approved GRN Cancelation Request"); if (At == 1) { tran.Commit(); } else { isSaved = false; } } else { isSaved = false; } if (isSaved != true) { if (TrackingNo != "") { WFTransaction.Close(TrackingNo); } tran.Rollback(); if (At == 1) { objAt.RoleBack(); } } } catch (Exception ex) { tran.Rollback(); if (At == 1) { objAt.RoleBack(); } throw new Exception("Unable to Add New record", ex); } finally { tran.Dispose(); if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Dispose(); } return(isSaved); }
public bool CancelGRNCancellationRequest(string TrackingNo) { Utility.LogException(new Exception(TrackingNo)); bool isSaved = false; SqlConnection conn = null; SqlTransaction tran = null; RequestforApprovedGRNCancelationBLL objEdit = new RequestforApprovedGRNCancelationBLL(); objEdit = objEdit.GetByTrackingNo(TrackingNo); this.Id = objEdit.Id; this.GRNId = objEdit.GRNId; this.RequestedBy = objEdit.RequestedBy; this.DateRequested = objEdit.DateRequested;; this.Remark = objEdit.Remark; // set status to cancelled this.Status = RequestforApprovedGRNCancelationStatus.Cancelled; this.GRN_Number = objEdit.GRN_Number; try { conn = Connection.getConnection(); tran = conn.BeginTransaction(); isSaved = RequestforApprovedGRNCancelationDAL.Update(tran, this); if (isSaved == true) { WFTransaction.Close(TrackingNo); string AppMode = Utility.GetApplicationName() + " - AppGRNCancel"; AuditTrailBLL objAT = new AuditTrailBLL(); if (objAT.saveAuditTrail(objEdit, this, AppMode, UserBLL.GetCurrentUser(), "Update-ApprovedGRNCancelRequest") == 1) { tran.Commit(); } else { tran.Rollback(); return(false); } } else { tran.Rollback(); return(false); } } catch (Exception ex) { tran.Rollback(); throw ex; } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } if (tran != null) { tran.Dispose(); } } return(isSaved); }