public bool UpdateGRNNumber(Guid Id, String oldSystemGRNNumber, string newSystemGRNNumber, string TrackingNo) { bool isSaved = true; SqlTransaction trans; SqlConnection conn = new SqlConnection(); conn = Connection.getConnection(); trans = conn.BeginTransaction(); try { isSaved = GRNDAL.UpDateGRNNumber(Id, oldSystemGRNNumber, newSystemGRNNumber, trans); if (isSaved == true) { int at = -1; AuditTrailBLL objAt = new AuditTrailBLL(); if (TrackingNo != "-1") { WFTransaction.WorkFlowManager(TrackingNo); } at = objAt.saveAuditTrailStringFormat("New System:GRN_Number = " + newSystemGRNNumber, "Old System :GRN_Number = " + oldSystemGRNNumber, "GRN No. Update ", UserBLL.GetCurrentUser(), WFStepName.UpdateGRNNo.ToString()); if (at == 1) { trans.Commit(); return(true); } else { trans.Rollback(); return(false); } } else { trans.Rollback(); return(false); } } catch (Exception ex) { trans.Rollback(); throw ex; } finally { if (trans != null) { trans.Dispose(); } if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(isSaved); }
public bool ReCreateGRN() { bool isSaved = false; SqlTransaction trans; SqlConnection conn = new SqlConnection(); conn = Connection.getConnection(); trans = conn.BeginTransaction(); string TrakingNo = ""; TrakingNo = this.TrackingNo; //RequestforEditGRNBLL objRequest = null; this.Status = (int)GRNStatus.New; //objRequest = RequestforEditGRNDAL.GetApprovedRequestByGRNID(this.Id); //if (objRequest != null) //{ // if (string.IsNullOrEmpty(objRequest.TrackingNo) == false) // { // TrakingNo = objRequest.TrackingNo; // } // else // { // throw new Exception("Unable to get GRN edit request data"); // } //} //else //{ // throw new Exception("Unable to get GRN edit request data"); //} try { isSaved = GRNDAL.ReCreate(this, trans); if (isSaved == true) { WFTransaction.WorkFlowManager(TrakingNo); } if (isSaved == true) { trans.Commit(); trans.Dispose(); conn.Close(); return(true); } } catch (Exception ex) { trans.Rollback(); trans.Dispose(); conn.Close(); throw ex; } return(false); }
public bool ClientAcceptance(string GRN_number, DateTime AccptedTimeStamp, bool CAStatus, string TrackingNo, GRNStatus prevStatus) { bool isSaved = false; SqlTransaction trans; SqlConnection conn = new SqlConnection(); conn = Connection.getConnection(); trans = conn.BeginTransaction(); int status; if (CAStatus == true) { status = 4; } else { status = 5; } try { isSaved = GRNDAL.ClientAcceptance(GRN_number, AccptedTimeStamp, CAStatus, status, trans); if (isSaved == true) { int At = -1; AuditTrailBLL objAt = new AuditTrailBLL(); string oldVal = "(GRNNo-" + GRN_number + ") , (Status-" + prevStatus.ToString() + ")"; string NewVal = "(GRNNo-" + GRN_number + ") , (Status-" + Status.ToString() + ")"; At = objAt.saveAuditTrailStringFormat(oldVal, NewVal, WFStepName.EditGRN.ToString(), UserBLL.GetCurrentUser(), "Change GRN Status"); if (At == 1) { WFTransaction.WorkFlowManager(TrackingNo); } else { isSaved = false; } } if (isSaved == true) { trans.Commit(); trans.Dispose(); conn.Close(); return(true); } } catch (Exception ex) { trans.Rollback(); trans.Dispose(); conn.Close(); throw ex; } return(false); }
public bool Edit(GradingDisputeBLL objOld) { bool isSaved = false; SqlConnection conn; SqlTransaction tran; conn = Connection.getConnection(); tran = conn.BeginTransaction(); try { isSaved = GradingDisputeDAL.UpdateGradingDisputeBLL(this, tran); if (isSaved == true) { //Update the WF step after cheking the status is set to approved. if (this.Status == 2) { WFTransaction.WorkFlowManager(this.TrackingNo); HttpContext.Current.Session["EditGradeDisputeTranNo"] = this.TrackingNo; } else if (this.Status == 3) { HttpContext.Current.Session["EditGradeDisputeTranNo"] = this.TrackingNo; } AuditTrailBLL ATobj = new AuditTrailBLL(); ATobj.saveAuditTrail(objOld, this, WFStepsName.EditGradeDispute.ToString(), UserBLL.GetCurrentUser(), "Edit Grade Dispute"); tran.Commit(); tran.Dispose(); conn.Close(); return(true); } else { tran.Rollback(); tran.Dispose(); conn.Close(); return(false); } } catch (Exception ex) { tran.Rollback(); tran.Dispose(); conn.Close(); throw ex; } }
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 static List <TrucksForSamplingBLL> GetRandomSample(Guid WarehouseId, int NumberOfTrucks) { List <TrucksForSamplingBLL> list = null; List <TrucksForSamplingBLL> listAll = null; List <TrucksForSamplingBLL> filteredList = new List <TrucksForSamplingBLL>(); list = TrucksForSamplingDAL.GetRandomSamplingIdWithin2Hours(WarehouseId, NumberOfTrucks); if (list == null) { list = new List <TrucksForSamplingBLL>(); } if (list.Count < NumberOfTrucks) { int numberofRandomRequired = 0; numberofRandomRequired = NumberOfTrucks - list.Count; listAll = TrucksForSamplingDAL.GetRandomTrucksForSamplingId(WarehouseId, NumberOfTrucks * 3); if (listAll != null) { if (listAll.Count <= numberofRandomRequired) { foreach (TrucksForSamplingBLL i in listAll) { list.Add(i); } } else { while (list.Count < NumberOfTrucks) { System.Random rnd = new Random(); int myRnd = rnd.Next(0, numberofRandomRequired); list.Add(listAll[myRnd]); } } } } if (list != null) { } else { list = TrucksForSamplingDAL.GetRandomTrucksForSamplingId(WarehouseId, NumberOfTrucks); } bool isSaved = false; SqlTransaction tran; SqlConnection connect = Connection.getConnection(); tran = connect.BeginTransaction(); AuditTrailBLL objAt = new AuditTrailBLL(); if (list == null) { return(null); } try { int i = 0; foreach (TrucksForSamplingBLL obj in list) { if (string.IsNullOrEmpty(obj.TrackingNo) == true) { break; } bool curSaved = false; obj.Id = Guid.NewGuid(); WFTransaction.UnlockTask(obj.TrackingNo); ECXWF.CMessage msg = WFTransaction.Request(obj.TrackingNo); if (msg == null) { // list.RemoveAt(i); } else { if (msg.Name == "GetTrucksReadyForSam") { curSaved = TrucksForSamplingDAL.InsertTruksForSampling(obj, tran); if (curSaved == true) { int at = -1; at = objAt.saveAuditTrail(obj, WFStepsName.GetTrucksReadyForSam.ToString(), UserBLL.GetCurrentUser(), "Add Trucks For sampling"); if (at == 1) { curSaved = true; } else { curSaved = false; } } if (curSaved == true) { // ECXWF.CMessage msg = WFTransaction.Request(obj.TrackingNo); if (msg != null) { if (msg.Name != "GetTrucksReadyForSam") { isSaved = false; throw new Exception("Invalid Task"); } else { HttpContext.Current.Session["msg"] = msg; WFTransaction.WorkFlowManager(obj.TrackingNo); filteredList.Add(obj); } } else { objAt.RoleBack(); //list.RemoveAt(i); } } else { // list.RemoveAt(i); } if (isSaved == false) { if (i == 0) { isSaved = curSaved; } else { isSaved = false; } } else { isSaved = curSaved; } i++; } else { // list.RemoveAt(i); } } } if (isSaved == true) { tran.Commit(); } else { filteredList = null; tran.Rollback(); } } catch (Exception ex) { objAt.RoleBack(); tran.Rollback(); filteredList = null; throw ex; } finally { tran.Dispose(); connect.Close(); } return(filteredList); }
public bool AddNew() { DriverInformationBLL objDriverInfo = new DriverInformationBLL(); objDriverInfo = objDriverInfo.GetById(this.DriverInformationId); TruckWeight objTruckWeight = null; if (objDriverInfo == null) { throw new Exception("Unbale To get Driver Information"); } else { objTruckWeight = new TruckWeight(); objTruckWeight.Id = Guid.NewGuid(); objTruckWeight.TruckPlateNo = objDriverInfo.PlateNumber; objTruckWeight.TrailerPlateNo = objDriverInfo.TrailerPlateNumber; if ((string.IsNullOrEmpty(objDriverInfo.PlateNumber) == true) && (string.IsNullOrEmpty(objDriverInfo.TrailerPlateNumber) == true)) { this.TruckWeightId = null; } else { objTruckWeight.DateWeighed = this.DateWeighed; objTruckWeight.Weight = this.TruckWeight; this.TruckWeightId = objTruckWeight.Id; } } bool isSaved = false; 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 { ScalingDAL.GetQueueNumber(Code, WarehouseId, currDate, out QueueNo, out PreWeightQueueNo); if (QueueNo == null || PreWeightQueueNo == null) { throw new Exception("Invalid Queue."); } this.Id = Guid.NewGuid(); this.QueueDate = currDate; this.QueueNo = (int)QueueNo; this.PreWeightQueueNo = (int)PreWeightQueueNo; this.WarehouseId = WarehouseId; SqlParameter[] paramList = new SqlParameter[18]; string spName = "spInsertScaling"; paramList[0] = DataAccessPoint.param("@ReceivigRequestId", SqlDbType.UniqueIdentifier, this.ReceivigRequestId); paramList[1] = DataAccessPoint.param("@DriverInformationId", SqlDbType.UniqueIdentifier, this.DriverInformationId); paramList[2] = DataAccessPoint.param("@GradingResultId", SqlDbType.UniqueIdentifier, this.GradingResultId); paramList[3] = DataAccessPoint.param("@ScaleTicketNumber", SqlDbType.NChar, this.ScaleTicketNumber, 50); paramList[4] = DataAccessPoint.param("@DateWeighed", SqlDbType.DateTime, this.DateWeighed); paramList[5] = DataAccessPoint.param("@GrossWeightWithTruck", SqlDbType.Float, this.GrossWeightWithTruck); paramList[6] = DataAccessPoint.param("@TruckWeight", SqlDbType.Float, this.TruckWeight); paramList[7] = DataAccessPoint.param("@GrossWeight", SqlDbType.Float, this.GrossWeight); paramList[8] = DataAccessPoint.param("@Status", SqlDbType.Int, this.Status); paramList[9] = DataAccessPoint.param("@Remark", SqlDbType.Text, this.Remark); paramList[10] = DataAccessPoint.param("@CreatedBy", SqlDbType.UniqueIdentifier, UserBLL.GetCurrentUser()); paramList[11] = DataAccessPoint.param("@WarehouseId", SqlDbType.UniqueIdentifier, this.WarehouseId); paramList[12] = DataAccessPoint.param("@PreWeightQueueNo", SqlDbType.Int, this.PreWeightQueueNo); paramList[13] = DataAccessPoint.param("@QueueNo", SqlDbType.Int, this.QueueNo); paramList[14] = DataAccessPoint.param("@QueueDate", SqlDbType.DateTime, this.QueueDate); paramList[15] = DataAccessPoint.param("@WeigherId", SqlDbType.UniqueIdentifier, this.WeigherId); paramList[16] = DataAccessPoint.param("@Id", SqlDbType.UniqueIdentifier, this.Id); paramList[17] = DataAccessPoint.param("@TruckWeightId", SqlDbType.UniqueIdentifier, this.TruckWeightId); DataAccessPoint dal = new DataAccessPoint(); if (dal.ExcuteProcedure(spName, paramList)) { isSaved = true; } //THE FOLLOWING METHOD [SaveNew()] ADDED BY SINISHAW if (isSaved == true && this.TruckWeightId != null && objTruckWeight != null && objTruckWeight.SaveNew() != true) { isSaved = false; } int at = -1; if (isSaved == true) { AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrail(this, WFStepsName.AddScalingInfo.ToString(), UserBLL.GetCurrentUser(), "Add Scaling"); } if (at == 1 && isSaved == true) { WFTransaction.WorkFlowManager(this.TrackingNo); } else { isSaved = false; } if (isSaved == true) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
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 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 UpdateGradingResult(List <GradingResultDetailBLL> list, Nullable <Guid> Id, string TrackingNo) { bool isSaved = false; SqlConnection conn = Connection.getConnection(); SqlTransaction tran = conn.BeginTransaction(); this.WarehouseId = UserBLL.GetCurrentWarehouse(); if (Id != null) { try { this.ID = (Guid)Id; if (GradingResultDAL.InactivateGradingResultDetails(this.ID, tran) == true) { int at = -1; AuditTrailBLL objAt = new AuditTrailBLL(); string strNew = "(Grading Result Id -" + this.ID.ToString() + "),(LastModifiedby-" + UserBLL.GetCurrentUser().ToString() + "),(LastModifiedTimeStamp-" + DateTime.Now.ToString() + ")"; at = objAt.saveAuditTrailStringFormat("Grading Factor Details Cancelled", strNew, WFStepsName.EditGradingResultDet.ToString(), UserBLL.GetCurrentUser(), "Cancel Grading Result Detail"); if (at == -1) { tran.Rollback(); isSaved = false; } else { GradingResultBLL objGR = new GradingResultBLL(); objGR = objGR.GetGradingResultById(this.ID); if (GradingResultDAL.UpdateGradingResult(this, tran) == true) { AuditTrailBLL objAtGR = new AuditTrailBLL(); at = objAtGR.saveAuditTrail(objGR, this, WFStepsName.EditGradingResult.ToString(), UserBLL.GetCurrentUser(), "Updating Grading Result"); if (at == -1) { tran.Rollback(); isSaved = false; return(isSaved); } GradingResultDetailBLL objDetail = new GradingResultDetailBLL(); isSaved = objDetail.Add(list, tran, Id); if (isSaved == true) { //Request ECXWF.CMessage msg = WFTransaction.Request(TrackingNo); if (msg != null) { if (msg.Name == "EditGradingResult") { WFTransaction.WorkFlowManager(TrackingNo, msg); } } } if (isSaved == false) { tran.Rollback(); isSaved = false; } else { tran.Commit(); isSaved = true; } } else { tran.Rollback(); isSaved = false; } } } else { tran.Rollback(); isSaved = false; } } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Dispose(); conn.Close(); } } return(isSaved); }
public Nullable <Guid> Add(List <GradingResultDetailBLL> list, string TrackingNo) { bool isSaved = false; if (this.IsSupervisor == true) { int count = 1; count = GradingResultDAL.GetNumberofSupervisorResults(this.GradingId); if (count > 0) { throw new Exception("Multiple Supervisor Grading result exception."); } } Nullable <Guid> Id = null; SqlConnection conn = Connection.getConnection(); SqlTransaction tran = conn.BeginTransaction(); this.WarehouseId = UserBLL.GetCurrentWarehouse(); this.ID = Guid.NewGuid(); this.CreatedBy = UserBLL.GetCurrentUser(); this.CreatedTimestamp = DateTime.Now; try { Id = (Guid)GradingResultDAL.InsertGradingResult(this, tran); if (Id != null) { // add audit trail int At = -1; AuditTrailBLL objAt = new AuditTrailBLL(); At = objAt.saveAuditTrail(this, WFStepsName.AddGradingResult.ToString(), UserBLL.GetCurrentUser(), "Add Grading result"); if (At == 1) { GradingResultDetailBLL objDetail = new GradingResultDetailBLL(); isSaved = objDetail.Add(list, tran, Id); if (isSaved == true) { isSaved = true; } else { if (At == 1) { objAt.RoleBack(); isSaved = false; } } if (isSaved == true) { GradingBLL objGrading = new GradingBLL(); objGrading = objGrading.GetById(this.GradingId); if (objGrading == null) { throw new Exception("Invalid Code.Please try again"); } else { if (string.IsNullOrEmpty(objGrading.TrackingNo) == true) { throw new Exception("Invalid Code.Please try again"); } } if (this.Status == GradingResultStatus.MoistureFailed || this.Status == GradingResultStatus.GeneralRequiementfail) { // Client Should Be Informed of the Grading Result. // WFTransaction.Close(objGrading.TrackingNo); WFTransaction.WorkFlowManager(objGrading.TrackingNo); } else { WFTransaction.WorkFlowManager(objGrading.TrackingNo); } HttpContext.Current.Session["AddGradingRecivedTranNo"] = objGrading.TrackingNo; } } else { isSaved = false; } } if (isSaved == true) { tran.Commit(); return(Id); } else { isSaved = false; tran.Rollback(); return(null); } } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Dispose(); conn.Close(); } }
//oct-18-2011 //update empty voucher entry error public bool Save(Guid DepositRequestId, string VoucherNo, Guid CoffeeTypeId, string SpecificArea, int NumberofBags, int NumberOfPlomps, int NumberOfPlompsTrailer, string CertificateNo, Guid CreatedBy, int Status, string TrackingNo) { SqlTransaction tran; bool isSaved = false; //get Tracking No. CommodityDepositeRequestBLL oC = new CommodityDepositeRequestBLL(); oC = oC.GetCommodityDepositeDetailById(DepositRequestId); TrackingNo = oC.TrackingNo; VoucherInformationBLL obj = new VoucherInformationBLL(); obj.DepositRequestId = DepositRequestId; obj.VoucherNo = VoucherNo; obj.CoffeeTypeId = CoffeeTypeId; obj.SpecificArea = SpecificArea; obj.NumberofBags = NumberofBags; obj.NumberOfPlomps = NumberOfPlomps; obj.NumberOfPlompsTrailer = NumberOfPlompsTrailer; obj.CertificateNo = CertificateNo; obj.CreatedBy = CreatedBy; obj.Status = Status; Voucher objSave = new Voucher(); SqlConnection conn = Connection.getConnection(); tran = conn.BeginTransaction(); AuditTrailBLL objAt = new AuditTrailBLL(); int AtSaved = -1; try { Guid VoucherId = Guid.Empty; VoucherId = objSave.InsertVoucherInformation(obj, tran); if (VoucherId == Guid.Empty) { isSaved = false; } else { obj.Id = VoucherId; if (objAt.saveAuditTrail(obj, WFStepsName.NewVoucherInfo.ToString(), UserBLL.GetCurrentUser(), "Insert Voucher") == 1) { AtSaved = 1; string msgFromWF = ""; msgFromWF = WFTransaction.GetMessage(TrackingNo); if (msgFromWF == "AddVoucherInfo") { WFTransaction.WorkFlowManager(TrackingNo); WFTransaction.UnlockTask(TrackingNo); HttpContext.Current.Session["msg"] = null; } tran.Commit(); isSaved = true; } else { tran.Rollback(); isSaved = false; } } } catch (Exception ex) { tran.Rollback(); if (AtSaved == 1) { objAt.RoleBack(); } throw ex; } finally { conn.Close(); tran.Dispose(); } return(isSaved); }
public Nullable <Guid> InsertSample(SamplingBLL objSampling, SamplerBLL objSampler, bool isMoisture) { bool issaved = false; SqlConnection conn = null; SqlTransaction trans = null; int at = -1; Nullable <Guid> DepositeRequestId = null; try { conn = Connection.getConnection(); trans = conn.BeginTransaction(); //using (TransactionScope scope = new TransactionScope()) //{ DepositeRequestId = new Guid(SamplingDAL.InsertSample(objSampling, trans).ToString()); if (DepositeRequestId == null) { trans.Rollback(); return(null); //throw new Exception("Invalid Sample Id."); } objSampling.Id = (Guid)DepositeRequestId; AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrail(objSampling, WFStepsName.AddSampleCoding.ToString(), UserBLL.GetCurrentUser(), "Get Sample Ticket"); if (at == 1) { at = -1; objSampler.SampleingTicketId = (Guid)DepositeRequestId; objSampler.Id = Guid.NewGuid(); issaved = SamplerDAL.InsertSampler(objSampler, trans); if (issaved == true) { HttpContext.Current.Session["msg"] = null; WFTransaction.UnlockTask(objSampling.TrackingNo); ECXWF.CMessage mess = WFTransaction.Request(objSampling.TrackingNo); HttpContext.Current.Session["msg"] = mess; if (mess.Name.Trim() == "GetSampleTicket".Trim()) { WFTransaction.WorkFlowManager(objSampling.TrackingNo); trans.Commit(); } else { objAt.RoleBack(); trans.Rollback(); DepositeRequestId = null; } } else { objAt.RoleBack(); trans.Rollback(); DepositeRequestId = null; } } else { trans.Rollback(); DepositeRequestId = null; throw new Exception("Unable to log Audit Trail"); } // scope.Complete(); // } } catch (Exception ex) { trans.Rollback(); DepositeRequestId = null; throw ex; } finally { trans.Dispose(); conn.Close(); } return(DepositeRequestId); }
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 EditCommodityDepositRequest(Guid ClientId, Guid commodityDepositRequestId, Guid commodityId, Guid representativeId, int productionYear, Guid woreda, float weight, int numberofBags, DateTime dateTimeRecived, string remark, int status, Guid lastModifiedBy, CommodityDepositeRequestBLL OldObject ) { int isSaved = 0; #region Validations //if (CommodityDepositRequestId == null) //{ // throw new Exception("Invalid Commodity Deposit Request Id"); //} //if (commodityId == null ) //{ // throw new Exception("Invalid Commodity Id"); //} //if (representativeId == null) //{ // throw new Exception("Invalid Representative Id"); //} //if (woreda == null) //{ // throw new Exception("Invalid Woreda"); //} //if (dateTimeRecived == null) //{ // throw new Exception("Invalid Date Time Recived"); //} //if (remark == null || remark == "") //{ // throw new Exception("Invalid Remark"); //} //if (status == null || status == "") //{ // throw new Exception("Invalid status"); //} //if (lastModifiedBy == null ) //{ // throw new Exception("Invalid last Modified by"); //} #endregion // has GRN on Rdit mood bool canBeEdited = false; canBeEdited = CommodityDepositeRequestBLL.isGRNEditable(commodityDepositRequestId); if (canBeEdited == false) { throw new GRNNotOnUpdateStatus("A GRN has already been created for this Deposit request, please request GRN the manger to edit this GRN."); } CommodityDepositeRequestBLL objEdit = new CommodityDepositeRequestBLL(); //NoClient objEdit = objEdit.GetCommodityDepositeDetailById(commodityDepositRequestId); string trNo = objEdit.TrackingNo; objEdit.Id = commodityDepositRequestId; objEdit.CommodityId = commodityId; objEdit.RepresentativeId = representativeId; objEdit.ProductionYear = productionYear; objEdit.WoredaId = woreda; objEdit.Weight = weight; objEdit.NumberofBags = numberofBags; objEdit.DateTimeRecived = dateTimeRecived; objEdit.Remark = remark; objEdit.Status = status; objEdit.LastModifiedBy = lastModifiedBy; objEdit.ClientId = ClientId; bool returnstatus = false; int atStatus = 0; SqlTransaction tran; SqlConnection conn = Connection.getConnection(); tran = conn.BeginTransaction(); try { isSaved = CommodityDepositRequest.UpdateCommodityDepositeRequest(objEdit, tran); if (isSaved == 0) { returnstatus = false; } else { //NoClient if (WFTransaction.GetMessage(trNo) == "UpdateClientNo") { if (objEdit.ClientId != Guid.Empty) { WFTransaction.UnlockTask(trNo); WarehouseApplication.ECXWF.CMessage msg = WFTransaction.Request(trNo); WFTransaction.WorkFlowManager(trNo, msg); } } AuditTrailBLL objAT = new AuditTrailBLL(); atStatus = objAT.saveAuditTrail(OldObject, objEdit, WFStepsName.ArrivalUpdate.ToString(), UserBLL.GetCurrentUser(), "Update Arrival"); if (atStatus == 1) { returnstatus = true; tran.Commit(); } } } catch { tran.Rollback(); } finally { tran.Dispose(); conn.Close(); } return(returnstatus); }
/// <summary> /// Gets the net weight by deducting the tare /// </summary> /// <param name="GrossWeight"></param> /// <param name="BagTypeId"></param> /// <param name="NoBags"></param> /// <returns></returns> /// public Nullable <Guid> Add(List <GRNServiceBLL> listGRNService) { bool IsSaved = false; bool canCreate = false;; try { canCreate = this.CanCreateGRNforGradingId(this.GradingId); } catch (Exception ex) { throw ex; } if (canCreate == false) { return(null); } Nullable <Guid> id = null; SqlTransaction tran; string warehousecode; warehousecode = WarehouseBLL.GetWarehouseCode(this.WarehouseId); SqlConnection conn = new SqlConnection(); conn = Connection.getConnection(); tran = conn.BeginTransaction(); try { id = GRNDAL.InsertNewGRN(this, warehousecode, tran); if (id != null) { if (listGRNService != null) { GRNServiceBLL objSer = new GRNServiceBLL(); IsSaved = objSer.Save((Guid)id, listGRNService, tran); //Audit Trail Both GRN And GRN Service. int at = -1; AuditTrailBLL objAt = new AuditTrailBLL(); this.Id = (Guid)id; at = objAt.saveAuditTrail(this, WFStepsName.AddGRN.ToString(), UserBLL.GetCurrentUser(), "Add New GRN"); if (at == 1) { IsSaved = true; } else { IsSaved = false; } } else { IsSaved = true; } if (IsSaved == true) { WFTransaction.WorkFlowManager(this.TrackingNo); tran.Commit(); } else { tran.Rollback(); } } else { tran.Rollback(); } } catch (Exception ex) { tran.Rollback(); throw new Exception("Unable to update database.", ex); } finally { tran.Dispose(); conn.Close(); } return(id); }
public bool Add(string WarehouseNo, string TrackingNo, List <GradingByBLL> list) { //Utility.LogException(new Exception(TrackingNo.ToString())); SqlTransaction trans; SqlConnection conn = Connection.getConnection(); bool isSaved = false; trans = conn.BeginTransaction(); try { SamplingResultBLL obj = new SamplingResultBLL(); obj = obj.GetSamplingResultById(this.SamplingResultId); //Tod Do if the code is from Regrading then the Tracking Number should change. string TranNoGradedispute = ""; TranNoGradedispute = TrackingNo; //if not from regrading. if (TranNoGradedispute == "") { throw new Exception("Unable to get Tracking Number."); } this.Id = Guid.NewGuid(); this.GradingCode = GetRandomCode(WarehouseNo); // TODO - Complete Work flow intgeration. //this.TrackingNo = TranNoGradedispute; this.TrackingNo = TrackingNo; isSaved = GradingDAL.InsertGrading(this, trans); if (isSaved == true) { // add Graders. GradingByBLL objGradingBy = new GradingByBLL(); isSaved = objGradingBy.Add(this.Id, list, trans); if (isSaved == false) { throw new CodeGenerationException("Can Not generarte Grading Code Exception"); } else { int at = -1; AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrail(this, WFStepName.GenerateGradingCode.ToString(), UserBLL.GetCurrentUser(), "Get Grading Code"); if (at == 1) { isSaved = true; } else { isSaved = false; } } } else { throw new CodeGenerationException("Can Not generarte Grading Code Exception"); } if (isSaved == true) { HttpContext.Current.Session["msg"] = WFTransaction.Request(TrackingNo); WFTransaction.WorkFlowManager(TrackingNo); trans.Commit(); } return(isSaved); } catch (Exception ex) { trans.Rollback(); throw ex; } finally { trans.Dispose(); conn.Close(); } }
public bool Update(string GRN_number, GRNStatus Status, GRNBLL objGRN, string TrackingNo, DateTime ManagerApprovedDateTime) { bool isSaved = false; SqlTransaction trans; SqlConnection conn = new SqlConnection(); conn = Connection.getConnection(); trans = conn.BeginTransaction(); GRNStatus PreviousStatus; PreviousStatus = (GRNStatus)objGRN.Status; if (objGRN == null) { throw new Exception("Unable to Load GRN Data"); } else { if (objGRN.Id == null || objGRN.Id == Guid.Empty) { throw new Exception("Invalid Grading Information "); } } GradingBLL objGrading = new GradingBLL(); objGrading = objGrading.GetById(objGRN.GradingId); objGrading.TrackingNo = TrackingNo; if (Status != GRNStatus.Cancelled) { if (objGrading == null) { throw new Exception("Unable to Load GRN Data"); } else { if (objGrading.TrackingNo == "") { throw new Exception("Unable to Load GRN Data"); } else { TrackingNo = objGrading.TrackingNo; } } } try { if (Status == GRNStatus.ManagerApproved) { isSaved = GRNDAL.SetGRNStatus(GRN_number, Status, trans, ManagerApprovedDateTime); if (isSaved == true) { int At = -1; AuditTrailBLL objAt = new AuditTrailBLL(); string oldVal = "(GRNNo-" + GRN_number + ") , (Status-" + PreviousStatus.ToString() + ")"; string NewVal = "(GRNNo-" + GRN_number + ") , (Status-" + Status.ToString() + ")"; At = objAt.saveAuditTrailStringFormat(oldVal, NewVal, WFStepName.EditGRN.ToString(), UserBLL.GetCurrentUser(), "Change GRN Status"); if (At == 1) { WarehouseRecieptBLL objWarehouseReciept = new WarehouseRecieptBLL(objGRN); if (objWarehouseReciept.Save() == true) { WFTransaction.WorkFlowManager(TrackingNo); isSaved = true; } else { isSaved = false; } } else { isSaved = false; } } else { isSaved = false; } } else if (Status == GRNStatus.Cancelled) { //Canceling Update isSaved = false; isSaved = GRNDAL.SetGRNStatus(GRN_number, Status, trans, ManagerApprovedDateTime); if (isSaved == true) { int At = -1; AuditTrailBLL objAt = new AuditTrailBLL(); string oldVal = "(GRNNo-" + GRN_number + ") , (Status-" + PreviousStatus.ToString() + ")"; string NewVal = "(GRNNo-" + GRN_number + ") , (Status-" + Status.ToString() + ")"; At = objAt.saveAuditTrailStringFormat(oldVal, NewVal, WFStepName.EditGRN.ToString(), UserBLL.GetCurrentUser(), "Change GRN Status"); if (At == 1) { ECXWF.CMessage msg = WFTransaction.Request(TrackingNo); if (msg == null) { throw new Exception("Unable to get WF Data."); } else if (msg.Name.Trim() == "EditGRN") { WFTransaction.WorkFlowManager(TrackingNo, msg); isSaved = true; } } } } else { isSaved = false; } #region Depricatedcode //// Cancel Implemented by web service. //if (Status == GRNStatus.Cancelled) //{ // WarehouseRecieptBLL objWarehouseReciept = new WarehouseRecieptBLL(); // isSaved = GRNDAL.UpdateGRN(GRN_number, Status, trans); // if (isSaved == true) // { // //isSaved = objWarehouseReciept.Cancel(this.Id); // if (isSaved == true) // { // int At = -1; // AuditTrailBLL objAt = new AuditTrailBLL(); // string oldVal = "(GRNNo-" + GRN_number + ") , (Status-" + PreviousStatus.ToString() + ")"; // string NewVal = "(GRNNo-" + GRN_number + ") , (Status-" + Status.ToString() + ")"; // At = objAt.saveAuditTrailStringFormat(oldVal, NewVal, WFStepName.EditGRN.ToString(), UserBLL.GetCurrentUser(), "Change GRN Status"); // if (At == 1) // { // isSaved = true; // } // else // { // isSaved = false; // } // } // } // else // { // throw new Exception("Unable to Cancel GRN."); // } // if (isSaved == true) // { // WFTransaction.WorkFlowManager(TrackingNo); // } //} #endregion if (isSaved == true) { trans.Commit(); trans.Dispose(); conn.Close(); return(true); } else { trans.Rollback(); trans.Dispose(); conn.Close(); } } catch (Exception ex) { trans.Rollback(); throw ex; } finally { trans.Dispose(); conn.Close(); } return(false); }
public bool UpdateSampleCodeReceived() { //check necessary data is Suplied. if ((this.Id == null) && (this.Id == Guid.Empty)) { throw new Exception("Invalid Parameter"); } if (IsCodeReceivedAtLab == null) { throw new Exception("Invalid Parameter,IsCodeReceivedAtLab Can't be null"); } if (CodeReceivedTimeStamp == null) { throw new Exception("Invalid Parameter, CodeReceivedTimeStamp Can't be null"); } bool isSaved = false; SqlTransaction tran = null; SqlConnection conn = null; int at = -1; AuditTrailBLL objAT = new AuditTrailBLL(); try { conn = Connection.getConnection(); tran = conn.BeginTransaction(); isSaved = GradingDAL.UpdateSampleCodeReceived(this.Id, (bool)this.IsCodeReceivedAtLab, (DateTime)this.CodeReceivedTimeStamp, this.LabTechRemark, tran); if (isSaved == true) { isSaved = false; at = objAT.saveAuditTrail(this, WFStepsName.CodeSampRec.ToString(), UserBLL.GetCurrentUser(), "Receive Sample Code"); WFTransaction.WorkFlowManager(this.TrackingNo); if (at == -1) { isSaved = false; } } if (isSaved == true) { tran.Commit(); } else { tran.Rollback(); } // update the Database } catch (Exception ex) { if (at != -1) { objAT.RoleBack(); } tran.Rollback(); throw ex; } finally { if (tran != null) { tran.Dispose(); } if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(isSaved); }
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 bool Confirm(List <TrucksForSamplingBLL> list) { SqlTransaction tran; SqlConnection conn; conn = Connection.getConnection(); tran = conn.BeginTransaction(); //List<MesseageTracking> msgList = new List<MesseageTracking>(); //msgList = (List<MesseageTracking>)HttpContext.Current.Session["msgList"]; try { bool isSaved = false; foreach (TrucksForSamplingBLL obj in list) { if (obj.Status == TrucksForSamplingStatus.Confirmed) { ECXWF.CMessage msg = null; try { msg = WFTransaction.Request(obj.TrackingNo.ToString().Trim()); } catch { msg = null; } if (msg != null) { if (msg.Name.Trim().ToUpper() == "ConfirmTrucksForSamp".ToUpper().Trim()) { isSaved = TrucksForSamplingDAL.UpdateConfirmation(obj, tran); if (isSaved == true) { string strNew = "(Id=" + obj.Id.ToString() + "),(Status-" + obj.Status.ToString() + "),(Remark-" + obj.Remark.ToString() + "),(LastModifiedBy-" + UserBLL.GetCurrentUser().ToString() + "),(LastModifiedTimeStamp-" + DateTime.Now.ToString() + ")"; int at = -1; AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrailStringFormat("Truck Ready For Sampling Confirmed", strNew, WFStepsName.ConfirmTrucksForsamp.ToString(), UserBLL.GetCurrentUser(), "Confirm Trucks for sampling"); if (at == 1) { #region depricatedcode //var xmsg = (from c in msgList // where c.trackingNo == obj.TrackingNo // select c.message).Single(); //ECXWF.CMessage msg = (ECXWF.CMessage)xmsg; //foreach (MesseageTracking i in msgList) //{ // if (i.trackingNo.Trim().ToUpper() == obj.TrackingNo.Trim().ToUpper()) // { // msg = i.message; // } //} //if (msg == null) //{ // throw new Exception("Invalid Message Exception"); //} #endregion WFTransaction.WorkFlowManager(obj.TrackingNo.Trim(), msg); } else { isSaved = false; } } else { isSaved = false; } } else { WFTransaction.UnlockTask(obj.TrackingNo.Trim()); } } } else { TrucksMissingOnSamplingBLL objTM = new TrucksMissingOnSamplingBLL(); objTM.Id = Guid.NewGuid(); objTM.TrucksForSamplingId = obj.Id; objTM.DateTimeReported = DateTime.Now; objTM.Remark = obj.Remark; objTM.Status = TrucksMissingOnSamplingStatus.New; objTM.CreatedBy = UserBLL.GetCurrentUser(); objTM.CreatedTimestamp = DateTime.Now; objTM.WarehouseId = UserBLL.GetCurrentWarehouse(); objTM.TrackingNo = obj.TrackingNo; isSaved = objTM.Save(tran); } if (isSaved == false) { tran.Rollback(); return(false); } } tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Dispose(); conn.Close(); } return(true); }
public bool Add(List <StackUnloadedBLL> list) { Nullable <Guid> Id = null; int Count = 1; Count = UnloadingDAL.GetNumberofUnloadingByGradeingResultId(this.GradingResultId); if (Count == 0) { SqlTransaction tran; SqlConnection conn = new SqlConnection(); conn = Connection.getConnection(); tran = conn.BeginTransaction(); try { Id = UnloadingDAL.InsertUnloadingInformation(this, tran); if (Id == null) { tran.Rollback(); conn.Close(); return(false); } else { // add the Stack information this.Id = (Guid)Id; StackUnloadedBLL stackObj = new StackUnloadedBLL(); bool isSavedList = false; isSavedList = stackObj.Add(tran, list, (Guid)Id); if (isSavedList == true) { int at = -1; AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrail(this, WFStepsName.AddUnloadingInfo.ToString(), UserBLL.GetCurrentUser(), "Add Unloading Information"); if (at == 1) { isSavedList = true; } else { isSavedList = false; } } if (isSavedList == true) { WFTransaction.WorkFlowManager(this.TrackingNo); } if (isSavedList == true) { tran.Commit(); return(true); } else { tran.Rollback(); return(false); } } } catch (Exception ex) { throw ex; } finally { tran.Dispose(); conn.Close(); } } else { return(false); } }
public bool Add() { //get Driver Info DriverInformationBLL objDriverInfo = new DriverInformationBLL(); objDriverInfo = objDriverInfo.GetById(this.DriverInformationId); WarehouseApplication.BLL.TruckWeight objTruckWeight = null; if (objDriverInfo == null) { throw new Exception("Unbale To get Driver Information"); } else { objTruckWeight = new TruckWeight(); objTruckWeight.Id = Guid.NewGuid(); if (string.IsNullOrEmpty(objDriverInfo.PlateNumber) != true) { objTruckWeight.TruckPlateNo = objDriverInfo.PlateNumber; } else { objTruckWeight.TruckPlateNo = String.Empty; } if (string.IsNullOrEmpty(objDriverInfo.TrailerPlateNumber) != true) { objTruckWeight.TrailerPlateNo = objDriverInfo.TrailerPlateNumber; } else { objTruckWeight.TrailerPlateNo = String.Empty; } if ((string.IsNullOrEmpty(objDriverInfo.PlateNumber) == true) && (string.IsNullOrEmpty(objDriverInfo.TrailerPlateNumber) == true)) { this.TruckWeightId = null; } else { objTruckWeight.DateWeighed = this.DateWeighed; objTruckWeight.Weight = this.TruckWeight; this.TruckWeightId = objTruckWeight.Id; } } bool isSaved = false; SqlTransaction tran = null; SqlConnection conn = new SqlConnection(); 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 { ScalingDAL.GetQueueNumber(Code, WarehouseId, currDate, out QueueNo, out PreWeightQueueNo); if (QueueNo == null || PreWeightQueueNo == null) { throw new Exception("Invalid Queue."); } this.Id = Guid.NewGuid(); this.QueueDate = currDate; this.QueueNo = (int)QueueNo; this.PreWeightQueueNo = (int)PreWeightQueueNo; conn = Connection.getConnection(); tran = conn.BeginTransaction(); this.WarehouseId = WarehouseId; isSaved = ScalingDAL.InsertScalingInformation(this, tran); if (isSaved == true) { if (this.TruckWeightId != null) { if (objTruckWeight != null) { if (objTruckWeight.Save(tran) != true) { if (isSaved == true) { isSaved = false; } } } } } int at = -1; if (isSaved == true) { AuditTrailBLL objAt = new AuditTrailBLL(); at = objAt.saveAuditTrail(this, WFStepsName.AddScalingInfo.ToString(), UserBLL.GetCurrentUser(), "Add Scaling"); } if (at == 1) { if (isSaved == true) { WFTransaction.WorkFlowManager(this.TrackingNo); } isSaved = true; } else { isSaved = false; } if (isSaved == true) { tran.Commit(); tran.Dispose(); conn.Close(); return(true);; } else { tran.Rollback(); tran.Dispose(); conn.Close(); return(false); } } catch (Exception ex) { tran.Rollback(); tran.Dispose(); conn.Close(); throw ex; } }