Esempio n. 1
0
        public decimal GetTotalTEMPdxoXdxu(int Id)
        {
            DoorxOrder doorxu = new DoorxOrder();
            string     sql    = @"[spGetTotalTEMPdxoXdxu] '{0}' ";

            sql = string.Format(sql, Id);

            try
            {
                DataSet ds = new DataSet();
                ds = _MB.CreaDS(ds, "DoorsxOrder", sql, _CN);
                if (ds.Tables["DoorsxOrder"].Rows.Count > 0)
                {
                    foreach (DataRow item in ds.Tables["DoorsxOrder"].Rows)
                    {
                        return(decimal.Parse(item["Total"].ToString()));
                    }
                }
                return(0);
            }
            catch (Exception err)
            {
                return(0);
            }
        }
Esempio n. 2
0
        public int UpdateDoorsxOrder(DoorxOrder pDoorsxOrder)
        {
            string SP = "";

            if (pDoorsxOrder.TEMP == true)
            {
                SP = "[spUpdateTEMPdxo]";
            }
            else
            {
                SP = "[spUpdateDoorsxOrder]";
            }
            decimal total = Convert.ToDecimal(pDoorsxOrder.ItemCost);
            decimal subto = Convert.ToDecimal(pDoorsxOrder.SubTotal);
            string  sql   = @"" + SP + "  '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}'";

            sql = string.Format(sql,
                                pDoorsxOrder.Id,
                                pDoorsxOrder.DoorxUser.Id,
                                pDoorsxOrder.Width.ToString().Replace(',', '.'),
                                pDoorsxOrder.DecimalsWidth.Id,
                                pDoorsxOrder.Height.ToString().Replace(',', '.'),
                                pDoorsxOrder.DecimalsHeight.Id,
                                pDoorsxOrder.Quantity,
                                total.ToString().Replace(',', '.'),
                                subto.ToString().Replace(',', '.'),
                                pDoorsxOrder.User.Id,
                                pDoorsxOrder.Status.Id,
                                pDoorsxOrder.ModificationUser,
                                pDoorsxOrder.Picture,
                                pDoorsxOrder.ProfilePicture,
                                pDoorsxOrder.DoorType.Id,
                                pDoorsxOrder.DoorOption.Id,
                                pDoorsxOrder.Descuento,
                                pDoorsxOrder.TotalDescuento.ToString().Replace(',', '.'),
                                pDoorsxOrder.HingeDirection.Id,
                                pDoorsxOrder.HingePositions.Id);
            try
            {
                return(_MB.EjecutarSQL(_CN, sql));
            }
            catch (Exception err)
            {
                throw err;
            }
        }
Esempio n. 3
0
        public bool UpdateDoorxOrder(int pIdOrder, DoorxOrder pDoorsOrder, int pIdUser)
        {
            try
            {
                lnDecimals      deci     = new lnDecimals();
                List <Decimals> listDeci = deci.GetAllDecimals();
                lnDoorsPrices   dp       = new lnDoorsPrices();
                lnDoorsxUser    DU       = new lnDoorsxUser();
                lnOrder         _LNOrder = new lnOrder();
                Order           Order    = null;
                if (pDoorsOrder.TEMP == true)
                {
                    Order = _LNOrder.GetTEMPorderById(pIdOrder);
                }
                else
                {
                    Order = _LNOrder.GetOrderById(pIdOrder);
                }

                lnUser _LNUser = new lnUser();
                Order.User = _LNUser.GetUserById(Order.User.Id);
                if (pDoorsOrder.TEMP == true)
                {
                    Order.DoorxUser = DU.GetAllTEMPdxu().Where(x => x.Order.Id == Order.Id).FirstOrDefault();
                }
                else
                {
                    Order.DoorxUser = DU.GetAllDoorsxUser().Where(x => x.Order.Id == Order.Id).FirstOrDefault();
                }
                Order.SubTotal = 0;
                Order.Quantity = 0;
                int Rail = 1;
                if (Order.DoorxUser.TopRail.Id == 3 || Order.DoorxUser.BottomRail.Id == 3 || Order.DoorxUser.DoorStyle.Id == 1009 || Order.DoorxUser.DoorStyle.Id == 1008)
                {
                    Rail = 2;
                }
                int panel = Order.DoorxUser.Panel.Id;
                if (Order.DoorxUser.DoorStyle.Id == 1002)
                {
                    Order.DoorxUser.Panel.Id = 5;
                }
                //else if (Order.DoorxUser.DoorStyle.Id == 1003)
                //{
                //    Order.DoorxUser.Panel.Id = 2;
                //}
                //if (Order.DoorxUser.Panel.Id == 2)
                //{
                //    panel = Order.DoorxUser.Panel.Id;
                //}
                if (Order.DoorxUser.DoorStyle.Id == 1010)
                {
                    panel = 2;
                }
                //else
                //{
                //    if (Order.DoorxUser.Panel.Id == 3)
                //    {
                //    Order.DoorxUser.Panel.Id = 5;
                //    }
                //}
                DoorsPrices DoorPrice = dp.GetDoorsPricesById(0, panel, Order.DoorxUser.Material.Id, Rail);
                decimal     deciW     = listDeci.Where(x => x.Id == pDoorsOrder.DecimalsWidth.Id).FirstOrDefault().Value;
                decimal     deciH     = listDeci.Where(x => x.Id == pDoorsOrder.DecimalsHeight.Id).FirstOrDefault().Value;
                decimal     Width     = pDoorsOrder.Width + deciW;
                decimal     Height    = pDoorsOrder.Height + deciH;
                decimal     result    = (((((Width * Height) / 12m) / 12m) - 1.5m) * DoorPrice.AdditionalSFPrice) + DoorPrice.BasePrice;
                if ((Order.DoorxUser.DoorStyle.Id == 1010))
                {
                    result = result / 100m * 80m;
                }

                if (result < DoorPrice.BasePrice)
                {
                    result = DoorPrice.BasePrice * 2;
                    if (Order.User.Descuento > 0)
                    {
                        decimal des = decimal.Parse(Order.User.Descuento.ToString()) / 100m;
                        pDoorsOrder.TotalDescuento = result * des;
                        result = result - (des * result);
                    }
                    if (pDoorsOrder.Descuento > 0)
                    {
                        decimal des = decimal.Parse(pDoorsOrder.Descuento.ToString()) / 100m;
                        pDoorsOrder.TotalDescuento = result * des;
                        result = result - (des * result);
                    }
                    else
                    {
                        if (Order.Descuento > 0)
                        {
                            decimal des = decimal.Parse(Order.Descuento.ToString()) / 100m;
                            pDoorsOrder.Descuento      = Order.Descuento;
                            pDoorsOrder.TotalDescuento = result * des;
                            result = result - (des * result);
                        }
                    }
                    pDoorsOrder.ItemCost = result;
                    pDoorsOrder.SubTotal = result * pDoorsOrder.Quantity;
                }
                else
                {
                    result = result * 2;
                    if (Order.User.Descuento > 0)
                    {
                        decimal des = decimal.Parse(Order.User.Descuento.ToString()) / 100m;
                        pDoorsOrder.TotalDescuento = result * des;
                        result = result - (des * result);
                    }
                    if (pDoorsOrder.Descuento > 0)
                    {
                        decimal des = decimal.Parse(pDoorsOrder.Descuento.ToString()) / 100m;
                        pDoorsOrder.TotalDescuento = result * des;
                        result = result - (des * result);
                    }
                    else
                    {
                        if (Order.Descuento > 0)
                        {
                            decimal des = decimal.Parse(Order.Descuento.ToString()) / 100m;
                            pDoorsOrder.Descuento      = Order.Descuento;
                            pDoorsOrder.TotalDescuento = result * des;
                            result = result - (des * result);
                        }
                    }
                    pDoorsOrder.ItemCost = result;
                    pDoorsOrder.SubTotal = result * pDoorsOrder.Quantity;
                }

                pDoorsOrder.DoorxUser        = Order.DoorxUser;
                pDoorsOrder.ModificationDate = DateTime.Now;
                pDoorsOrder.ModificationUser = pIdUser;
                pDoorsOrder.ProfilePicture   = DU.BuscarProfilePicture(Order.DoorxUser.OutsideEdgeProfile.Id, Order.DoorxUser.InsideEdgeProfile.Id, Order.DoorxUser.Panel.Id);
                pDoorsOrder.Picture          = DU.BuscarDoorPicture(pDoorsOrder);
                int retorno = _AD.UpdateDoorsxOrder(pDoorsOrder);

                decimal subTotal = _AD.GetTotalDoorxOrderByDoorxUser(Order.DoorxUser.Id);
                int     cantidad = _AD.GetAllDoorxOrderByDoorxUser(Order.DoorxUser.Id).Sum(x => x.Quantity);
                if (subTotal > 0)
                {
                    Order.SubTotal         = subTotal;
                    Order.Tax              = 0.0825m * Order.SubTotal;
                    Order.Total            = Order.Tax + Order.SubTotal;
                    Order.Quantity         = cantidad;
                    Order.ModificationDate = DateTime.Now;
                    Order.ModificationUser = pIdUser;
                    _LNOrder.UpdateOrder(Order);
                }


                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 4
0
        public int InsertDoorsxOrder(DoorxOrder pDoorsxOrder)
        {
            try
            {
                lnDecimals      deci     = new lnDecimals();
                List <Decimals> listDeci = deci.GetAllDecimals();
                lnDoorsPrices   dp       = new lnDoorsPrices();
                lnDoorsxUser    DU       = new lnDoorsxUser();
                lnOrder         _LNOrder = new lnOrder();
                Order           item     = null;
                DoorsxUser      DoorUser = null;
                if (pDoorsxOrder.TEMP == true)
                {
                    DoorUser      = DU.GetTEMPdxuById(pDoorsxOrder.DoorxUser.Id);
                    DoorUser.TEMP = true;
                    item          = _LNOrder.GetTEMPorderById(DoorUser.Order.Id);
                    item.TEMP     = true;
                }
                else
                {
                    item     = _LNOrder.GetOrderByUser(pDoorsxOrder.User.Id).Where(x => x.Status.Id == 4).FirstOrDefault();
                    DoorUser = DU.GetAllDoorsxUser().Where(x => x.Order.Id == item.Id).FirstOrDefault();
                }
                pDoorsxOrder.DoorxUser = DoorUser;
                int Rail = 1;
                if (DoorUser.TopRail.Id == 3 || DoorUser.BottomRail.Id == 3 || DoorUser.DoorStyle.Id == 1009 || DoorUser.DoorStyle.Id == 1008)
                {
                    Rail = 2;
                }
                int panel = 5;
                if (DoorUser.Panel.Id == 2)
                {
                    panel = DoorUser.Panel.Id;
                }
                if (DoorUser.DoorStyle.Id == 1010)
                {
                    panel = 2;
                }
                lnUser _LNUser = new lnUser();
                User   u       = new User();
                u = _LNUser.GetUserById(pDoorsxOrder.User.Id);
                DoorsPrices DoorPrice = dp.GetDoorsPricesById(0, panel, DoorUser.Material.Id, Rail);
                decimal     deciW     = listDeci.Where(x => x.Id == pDoorsxOrder.DecimalsWidth.Id).FirstOrDefault().Value;
                decimal     deciH     = listDeci.Where(x => x.Id == pDoorsxOrder.DecimalsHeight.Id).FirstOrDefault().Value;
                decimal     Width     = pDoorsxOrder.Width + deciW;
                decimal     Height    = pDoorsxOrder.Height + deciH;
                decimal     a         = 1;
                decimal     b         = 1;
                decimal     aux       = 1;
                while (!(aux == deciW))
                {
                    aux = a / b;
                    if (aux < deciW)
                    {
                        a++;
                    }
                    else if (aux > deciW)
                    {
                        a--;
                        b++;
                    }
                }
                string fracc = a.ToString() + "/" + b.ToString();
                pDoorsxOrder.User = u;
                decimal result = (((((Width * Height) / 12m) / 12m) - 1.5m) * DoorPrice.AdditionalSFPrice) + DoorPrice.BasePrice;
                if ((DoorUser.DoorStyle.Id == 1010))
                {
                    result = result / 100m * 80m;
                }
                if (result < DoorPrice.BasePrice)
                {
                    result = DoorPrice.BasePrice * 2;
                    if (pDoorsxOrder.User.Descuento > 0)
                    {
                        decimal des = decimal.Parse(pDoorsxOrder.User.Descuento.ToString()) / 100m;
                        result = result - (des * result);
                    }
                    if (pDoorsxOrder.Descuento > 0)
                    {
                        decimal des = decimal.Parse(pDoorsxOrder.Descuento.ToString()) / 100m;
                        pDoorsxOrder.TotalDescuento = result * des;
                        result = result - (des * result);
                    }
                    pDoorsxOrder.ItemCost = result;
                    pDoorsxOrder.SubTotal = result * pDoorsxOrder.Quantity;
                }
                else
                {
                    result = result * 2;
                    if (pDoorsxOrder.User.Descuento > 0)
                    {
                        decimal des = decimal.Parse(pDoorsxOrder.User.Descuento.ToString()) / 100m;
                        pDoorsxOrder.TotalDescuento = result * des;
                        result = result - (des * result);
                    }
                    if (pDoorsxOrder.Descuento > 0)
                    {
                        decimal des = decimal.Parse(pDoorsxOrder.Descuento.ToString()) / 100m;
                        pDoorsxOrder.TotalDescuento = result * des;
                        result = result - (des * result);
                    }
                    pDoorsxOrder.ItemCost = result;
                    pDoorsxOrder.SubTotal = result * pDoorsxOrder.Quantity;
                }

                if (DoorUser.isDrill == false)
                {
                    pDoorsxOrder.HingeDirection.Id = 3;
                    pDoorsxOrder.HingePositions.Id = 2;
                }
                else
                {
                    pDoorsxOrder.HingeDirection.Id = pDoorsxOrder.HingeDirection.Id;
                    pDoorsxOrder.HingePositions.Id = 2;
                }
                pDoorsxOrder.CreationDate     = DateTime.Now;
                pDoorsxOrder.ModificationDate = DateTime.Now;
                pDoorsxOrder.CreatorUser      = pDoorsxOrder.User.Id;
                pDoorsxOrder.ModificationUser = pDoorsxOrder.User.Id;
                pDoorsxOrder.ProfilePicture   = DU.BuscarProfilePicture(DoorUser.OutsideEdgeProfile.Id, DoorUser.InsideEdgeProfile.Id, DoorUser.Panel.Id);
                pDoorsxOrder.Picture          = DU.BuscarDoorPicture(pDoorsxOrder);
                int retorno = _AD.InsertDoorsxOrder(pDoorsxOrder);
                item.SubTotal = item.SubTotal + pDoorsxOrder.SubTotal;
                item.Tax      = 0.0825m * item.SubTotal;
                item.Total    = item.Tax + item.SubTotal;
                item.Quantity = item.Quantity + pDoorsxOrder.Quantity;
                _LNOrder.UpdateOrder(item);
                return(retorno);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 5
0
        public DoorxOrder GetTEMPdxoById(int Id)
        {
            DoorxOrder doorxu = new DoorxOrder();
            string     sql    = @"[spGetTEMPdxo] '{0}' ";

            sql = string.Format(sql, Id);

            try
            {
                DataSet ds = new DataSet();
                ds = _MB.CreaDS(ds, "DoorsxOrder", sql, _CN);
                if (ds.Tables["DoorsxOrder"].Rows.Count > 0)
                {
                    foreach (DataRow item in ds.Tables["DoorsxOrder"].Rows)
                    {
                        int val = 0;
                        if (int.TryParse(item["Descuentos"].ToString(), out val))
                        {
                            val = int.Parse(item["Descuentos"].ToString());
                        }
                        decimal valu = 0;
                        if (decimal.TryParse(item["TotalDescuento"].ToString(), out valu))
                        {
                            valu = decimal.Parse(item["TotalDescuento"].ToString());
                        }
                        doorxu = new DoorxOrder()
                        {
                            Id        = int.Parse(item["Id"].ToString()),
                            DoorxUser = new DoorsxUser()
                            {
                                Id = int.Parse(item["IdDoorxUser"].ToString())
                            },
                            Width         = decimal.Parse(item["Width"].ToString()),
                            DecimalsWidth = new Decimals()
                            {
                                Id = int.Parse(item["IdDecimalsWidth"].ToString()), Description = item["DescriptDW"].ToString(), Value = decimal.Parse(item["ValueDW"].ToString())
                            },
                            Height         = decimal.Parse(item["Height"].ToString()),
                            DecimalsHeight = new Decimals()
                            {
                                Id = int.Parse(item["IdDecimalsHeight"].ToString()), Description = item["DescriptDH"].ToString(), Value = decimal.Parse(item["ValueDH"].ToString())
                            },
                            Quantity = int.Parse(item["Quantity"].ToString()),
                            ItemCost = decimal.Parse(item["ItemCost"].ToString()),
                            SubTotal = decimal.Parse(item["SubTotal"].ToString()),
                            User     = new User()
                            {
                                Id = int.Parse(item["IdUser"].ToString())
                            },
                            Status = new Status()
                            {
                                Id = int.Parse(item["IdStatus"].ToString()), Description = item["DescripStatus"].ToString()
                            },
                            CreationDate     = DateTime.Parse(item["CreationDate"].ToString()),
                            ModificationDate = DateTime.Parse(item["ModificationDate"].ToString()),
                            CreatorUser      = int.Parse(item["CreatorUser"].ToString()),
                            ModificationUser = int.Parse(item["ModificationUser"].ToString()),
                            Picture          = item["Picture"].ToString(),
                            ProfilePicture   = item["ProfilePicture"].ToString(),
                            DoorType         = new DoorType()
                            {
                                Id = int.Parse(item["IdDoorType"].ToString()), Description = item["DescripDoorType"].ToString()
                            },
                            DoorOption = new DoorOption()
                            {
                                Id = int.Parse(item["IdDoorOption"].ToString()), Description = item["DescripDoorOption"].ToString()
                            },
                            Descuento      = val,
                            TotalDescuento = valu,
                            HingeDirection = new HingeDirection()
                            {
                                Id = int.Parse(item["IdHingeDirection"].ToString()), Direction = item["HingerDirection"].ToString(),
                            },
                            HingePositions = new HingePositions()
                            {
                                Id = int.Parse(item["IdHingePositions"].ToString()), Position1 = item["HP1"].ToString(), Position2 = item["HP2"].ToString(), Position3 = item["HP3"].ToString(), Position4 = item["HP4"].ToString(), Position5 = item["HP5"].ToString(),
                            },
                        };
                    }
                }
                return(doorxu);
            }
            catch (Exception err)
            {
                throw;
            }
        }