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); }
/// <summary> /// A function that collects values of CDR, Driver and Voucher information and Save it using /// DataAccessPoint Class from DAL through Stored Procedure called "ExecuteProcedure" /// </summary> /// <param name="TransactionTypeId"></param> /// <param name="objDriver"></param> /// <param name="objVoucher"></param> /// <returns> /// Id with type Guid to form. Id is PK for CDR and FK for Driver and Voucher Information /// </returns> public Guid AddArrival(Guid TransactionTypeId, DriverInformationBLL objDriver, VoucherInformationBLL objVoucher) { try { this.Id = Guid.NewGuid(); string TransactionNo = WFTransaction.GetTransaction(TransactionTypeId); this.TransactionId = TransactionNo; DataAccessPoint objDAL = new DataAccessPoint(); objDAL.ExcuteProcedure("spInsertArrival", ParamList(this, objDriver, objVoucher)); return(Id); //1st argument is the procedure name //2nd arguemnt is a method found in this class that returns all tables parameter list //SaveByText found at DAL and it executes the procedure } catch (Exception ex) { throw new Exception("Failed to save arrival information! " + ex.Message.ToString()); } }
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(); } } }
/// <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); }
public bool Save() { SqlTransaction trans; Guid TransactionTypeId = Guid.Empty; string TransactionNo = ""; SqlConnection conn; conn = Connection.getConnection(); trans = conn.BeginTransaction(); bool isSaved = false;; try { try { TransactionTypeId = TransactionTypeProvider.GetTransactionTypeId("CoffeeResample"); } catch { throw new Exception("Unable to get Transaction Type.Please contact the Administrator"); } try { TransactionNo = WFTransaction.GetTransaction(TransactionTypeId, trans); this.TrackingNo = TransactionNo; } catch { throw new Exception("Unable to get Tracking Nunber.Please contact the Administrator"); } //entered as New. this.Status = ReSamplingStatus.New; this.Id = Guid.NewGuid(); isSaved = ReSamplingDAL.Insert(this, trans); if (isSaved == true) { int at = -1; AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrail(this, WFStepsName.AddReSamplingRequest.ToString(), UserBLL.GetCurrentUser(), "Add Re-sampling Request"); if (at == 1) { trans.Commit(); return(true); } else { trans.Rollback(); return(false); } } else { return(false); } } catch (Exception ex) { if (trans != null) { trans.Rollback(); } throw new Exception("An Error Has occured please try Again.If the error persists Contact Administrator", ex); } finally { trans.Dispose(); if (conn != null) { if (conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } } }
public bool Add() { Guid TransactionTypeId = Guid.Empty; try { TransactionTypeId = TransactionTypeProvider.GetTransactionTypeId("RegularCoffeeGradeDisputeId"); } catch { throw new Exception("Missing Configuration Setting"); } if (HasOpenGradingDispute(this.GradingId) == true) { throw new Exception("an open Grading dispute alrady exists."); } SqlConnection conn; SqlTransaction tran; conn = Connection.getConnection(); tran = conn.BeginTransaction(); string TransactionNo; bool isSaved = false; try { TransactionNo = WFTransaction.GetTransaction(TransactionTypeId, tran); this.TrackingNo = TransactionNo; this.CreatedBy = UserBLL.GetCurrentUser(); this.CreatedTimestamp = DateTime.Now; isSaved = GradingDisputeDAL.InsertGradingDisputeBLL(this, tran); int At = -1; AuditTrailBLL objAt = new AuditTrailBLL(); if (isSaved == true) { At = objAt.saveAuditTrail(this, WFStepsName.AddGradingResult.ToString(), UserBLL.GetCurrentUser(), "Add Grade Dispute"); if (At != 1) { isSaved = false; } } if (isSaved == true) { HttpContext.Current.Session["CoffeeRegradeTranNo"] = this.TrackingNo; tran.Commit(); return(true); } else { tran.Rollback(); return(false); } } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Dispose(); 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); }