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 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); }