Exemple #1
0
        public List <GRNServiceBLL> GetByGRNId(Guid Id)
        {
            List <GRNServiceBLL>        list   = null;
            List <WarehouseServicesBLL> listWS = null;

            try
            {
                list = GRNServiceDAL.GetByGRNId(Id);
                WarehouseServicesBLL objservice = new WarehouseServicesBLL();
                listWS = objservice.GetServices();
                if (list != null)
                {
                    listWS = objservice.GetActiveServices();
                    if (listWS != null)
                    {
                        var x = from grnser in list
                                join wservice in listWS on grnser.ServiceId equals wservice.Id
                                select new { grnser.Id, grnser.GRNId, grnser.Quantity, grnser.Status, grnser.ServiceId, ServiceName = wservice.Name };
                        list = new List <GRNServiceBLL>();
                        foreach (var i in x)
                        {
                            GRNServiceBLL o = new GRNServiceBLL();
                            o.Id          = i.Id;
                            o.GRNId       = i.GRNId;
                            o.ServiceId   = i.ServiceId;
                            o.ServiceName = i.ServiceName;
                            o.Status      = i.Status;
                            o.Quantity    = i.Quantity;
                            list.Add(o);
                        }
                        return(list);
                    }
                    else
                    {
                        throw new Exception("unable to get look up information.");
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        /// <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);
        }