コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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();
                }
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }