Esempio n. 1
0
        // 出餐明細
        public ActionResult Detail()
        {
            RepositoryOrder       repo = new RepositoryOrder();
            List <OrderViewModel> data = repo.Query();

            return(View(data));
        }
Esempio n. 2
0
        public ActionResult RefreshOrder()
        {
            RepositoryOrder       repo = new RepositoryOrder();
            List <OrderViewModel> data = repo.Query();

            return(Json(data));
        }
Esempio n. 3
0
        public Factory(string server, string port, string user, string pass, string dbname)
        {
            string ConnectionString = "Server=" + server + "; Port=" + port + "; User Id=" + user + "; Password="******"; Database=" + dbname + ";";

            NpgsqlConnection = new NpgsqlConnection(ConnectionString);
            SqlConnection    = new SqlConnection(NpgsqlConnection);
            OpenConnection();
            RepositoryBusiness_Trip  = new RepositoryBusiness_Trip(SqlConnection);
            RepositoryChair          = new RepositoryChair(SqlConnection);
            RepositoryContract       = new RepositoryContract(SqlConnection);
            RepositoryDegree         = new RepositoryDegree(SqlConnection);
            RepositoryEmployee_Sheet = new RepositoryEmployee_Sheet(SqlConnection);
            RepositoryOrder          = new RepositoryOrder(SqlConnection);
            RepositoryPositions      = new RepositoryPositions(SqlConnection);
            RepositorySick_List      = new RepositorySick_List(SqlConnection);
            RepositoryStaff          = new RepositoryStaff(SqlConnection);
            RepositoryStaff_Degree   = new RepositoryStaff_Degree(SqlConnection);
            RepositoryStaff_Title    = new RepositoryStaff_Title(SqlConnection);
            RepositoryTime_Sheet     = new RepositoryTime_Sheet(SqlConnection);
            RepositoryTitle          = new RepositoryTitle(SqlConnection);
            //RepositoryTransfer_Training = new RepositoryTransfer_Training(SqlConnection);
            RepositoryVacations = new RepositoryVacations(SqlConnection);
            reg = new Registration(SqlConnection);
            log = new Login(SqlConnection);
        }
        private void bbiSauvegarderFermer_ItemClick(object sender, ItemClickEventArgs e)
        {
            IsOrderLineModified = false;

            if (_newOrderLine)
            {
                OrderLine = FactoryOrder.CreateOrderLine(comboBoxStock.SelectedItem as Stock, comboBoxProduit.Text,
                                                         Convert.ToInt32(textEditQuantité.EditValue.ToString()));
                MessageBox.Show(Resources.succesAdd);
            }
            else
            {
                var orderLineModif = new OrderLine
                {
                    id       = OrderLineOut.Id,
                    Product  = comboBoxProduit.SelectedItem as Product,
                    Quantity = Convert.ToInt32(textEditQuantité.EditValue.ToString())
                };

                var repositoryOrder = new RepositoryOrder();
                repositoryOrder.Save(OrderLineOut.IdOrder, orderLineModif);
                MessageBox.Show(Resources.succesUpdate);
            }

            Close();
        }
Esempio n. 5
0
        public ActionResult Finish(long RecordID)
        {
            RepositoryOrder repo = new RepositoryOrder();
            AuthModel       auth = RepositoryAuthModel.GetAuthModel(HttpContext.User.Identity as FormsIdentity);
            OperationResult <OrderViewModel> result = repo.Finish(RecordID, auth);

            return(Json(result));
        }
        // 點餐明細
        public ActionResult OrderDetail(string Date)
        {
            RepositoryOrder       repo = new RepositoryOrder();
            List <OrderViewModel> data = repo.Query().Where(x => x.UpdateTime.ToString("yyyy/MM/dd").Equals(Date)).ToList();

            ViewBag.Date = Date;

            return(PartialView("_OrderDetail", data));
        }
Esempio n. 7
0
 public EShopUnitOfWork(ShopContext context)
 {
     this.context = context;
     RepostiryCustomer = new RepositoryCustomer(context);
     RepositoryBook = new RepositoryBook(context);
     RepositoryOrder = new RepositoryOrder(context);
     RepositoryGenre = new RepositoryGenre(context);
     RepositoryAutor = new RepositoryAutor(context);
 }
        public void RetrevieValid()
        {
            var repositoryOrder = new RepositoryOrder();
            var expected        = new Order(10)
            {
                ShippingDate = new DateTimeOffset(DateTime.Now.Year, 4, 14, 10, 00, 00, new TimeSpan(7, 0, 0))
            };

            var actual = repositoryOrder.Retrive(10);

            Assert.AreEqual(expected.ShippingDate, actual.ShippingDate);
        }
        static void SeedData()
        {
            RepositoryOrder repositoryOrder = new RepositoryOrder(DbContextSingleton.Instance.Context);
            Order           order           = new Order();

            order.Customer.Name = "jeff";
            order.Store         = new NewYorkStore();
            order.Pizza.Add(new MeatPizza());
            order.Pizza.Add(new HawaiianPizza());

            repositoryOrder.Add(order);
        }
        internal FrmEditBdc(ModelViewBdc bdc, bool newBdc, string caption)
        {
            InitializeComponent();
            LigneCommande = null;
            var repositoryClient = new RepositoryClient();
            var repositoryStock  = new RepositoryStock();
            var repositoryOrder  = new RepositoryOrder();

            _editBdcPresenter = new EditBdcPresenterPage(this, repositoryClient, repositoryStock, repositoryOrder, OrderLines);
            _editBdcPresenter.Display();

            comboBoxClients.DataSource    = Clients.OrderBy(cl => cl.Name).ToList();
            comboBoxClients.DisplayMember = "Name";
            comboBoxClients.ValueMember   = "Name";
            comboBoxPriorite.DataSource   = Enum.GetValues(typeof(Priorite));
            comboBoxEtat.DataSource       = Enum.GetValues(typeof(GestionCommande));

            gridViewOrderLine.Columns[0].FieldName = "Product.Name";

            if (!newBdc)
            {
                IdOrder = bdc.Id;
                textEditNumCommande.Text      = bdc.NumCommande.ToString(CultureInfo.InvariantCulture);
                comboBoxClients.SelectedValue = bdc.NameClient;
                dateEditLivraison.Text        = bdc.DateLivraison.ToShortDateString();
                memoEditAdresssLivraion.Text  = bdc.AdresseLivraison;
                comboBoxPriorite.SelectedItem = bdc.Priorite;
                comboBoxEtat.SelectedItem     = bdc.Etat;
                dateEditCommande.Text         = bdc.Datecommande.ToShortDateString();
                var orderline1 = new OrderLine();
                foreach (var lc in bdc.OrderLines)
                {
                    orderline1.id       = lc.Id;
                    orderline1.Product  = lc.Product;
                    orderline1.Quantity = lc.Quantity;
                    OrderLines.Add(new OrderLine {
                        id = lc.Id, Product = lc.Product, Quantity = lc.Quantity
                    });
                }
                radiogroupLivraisonSurPlace.EditValue = bdc.LivraisonSurPlace;
                GCOrderLine.DataSource = OrderLines;
            }
            else
            {
                GCOrderLine.DataSource = OrderLines;
            }

            IsBdcModified = false;
            _newBdc       = newBdc;
            _sourceBdc    = bdc;
        }
        /// <inheritdoc/>
        public async Task <ViewerRepositoriesModel> ReadViewerRepositories(HostAddress address)
        {
            if (readViewerRepositories == null)
            {
                var order = new RepositoryOrder
                {
                    Field     = RepositoryOrderField.Name,
                    Direction = OrderDirection.Asc
                };

                var affiliation = new RepositoryAffiliation?[]
                {
                    RepositoryAffiliation.Owner, RepositoryAffiliation.Collaborator
                };

                var repositorySelection = new Fragment <Repository, RepositoryListItemModel>(
                    "repository",
                    repo => new RepositoryListItemModel
                {
                    IsFork    = repo.IsFork,
                    IsPrivate = repo.IsPrivate,
                    Name      = repo.Name,
                    Owner     = repo.Owner.Login,
                    Url       = new Uri(repo.Url),
                });

                readViewerRepositories = new Query()
                                         .Viewer
                                         .Select(viewer => new ViewerRepositoriesModel
                {
                    Owner        = viewer.Login,
                    Repositories = viewer.Repositories(null, null, null, null, null, null, null, order, affiliation, null)
                                   .AllPages()
                                   .Select(repositorySelection).ToList(),
                    Organizations = viewer.Organizations(null, null, null, null).AllPages().Select(org => new
                    {
                        org.Login,
                        Repositories = org.Repositories(null, null, null, null, null, null, null, order, null, null)
                                       .AllPages()
                                       .Select(repositorySelection).ToList()
                    }).ToDictionary(x => x.Login, x => (IReadOnlyList <RepositoryListItemModel>)x.Repositories),
                }).Compile();
            }

            var graphql = await graphqlFactory.CreateConnection(address).ConfigureAwait(false);

            var result = await graphql.Run(readViewerRepositories).ConfigureAwait(false);

            return(result);
        }
Esempio n. 12
0
        /// <inheritdoc/>
        public async Task <ViewerRepositoriesModel> ReadViewerRepositories(HostAddress address, bool refresh = false)
        {
            if (readViewerRepositories == null)
            {
                var order = new RepositoryOrder
                {
                    Field     = RepositoryOrderField.PushedAt,
                    Direction = OrderDirection.Desc
                };

                var repositorySelection = new Fragment <Repository, RepositoryListItemModel>(
                    "repository",
                    repo => new RepositoryListItemModel
                {
                    IsFork    = repo.IsFork,
                    IsPrivate = repo.IsPrivate,
                    Name      = repo.Name,
                    Owner     = repo.Owner.Login,
                    Url       = new Uri(repo.Url),
                });

                readViewerRepositories = new Query()
                                         .Viewer
                                         .Select(viewer => new ViewerRepositoriesModel
                {
                    Owner        = viewer.Login,
                    Repositories = viewer.Repositories(null, null, null, null, null, null, null, order, null, null)
                                   .AllPages()
                                   .Select(repositorySelection).ToList(),
                    ContributedToRepositories = viewer.RepositoriesContributedTo(100, null, null, null, null, null, null, order, null)
                                                .Nodes
                                                .Select(repositorySelection).ToList(),
                    Organizations = viewer.Organizations(null, null, null, null).AllPages().Select(org => new
                    {
                        org.Login,
                        Repositories = org.Repositories(100, null, null, null, null, null, null, order, null, null)
                                       .Nodes
                                       .Select(repositorySelection).ToList()
                    }).ToDictionary(x => x.Login, x => (IReadOnlyList <RepositoryListItemModel>)x.Repositories),
                }).Compile();
            }

            var graphql = await graphqlFactory.CreateConnection(address).ConfigureAwait(false);

            var result = await graphql.Run(readViewerRepositories, cacheDuration : TimeSpan.FromHours(1), refresh : refresh).ConfigureAwait(false);

            return(result);
        }
        private void FrmEditOrderLine_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (IsOrderLineModified)
            {
                DialogResult result = XtraMessageBox.Show(this, TagResources.SaveBeforeClose, Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
                if (result == DialogResult.Yes)
                {
                    if (_newOrderLine)
                    {
                        OrderLine = FactoryOrder.CreateOrderLine(comboBoxStock.SelectedItem as Stock, comboBoxProduit.Text,
                                                                 Convert.ToInt32(textEditQuantité.EditValue.ToString()));
                        MessageBox.Show(Resources.succesAdd);
                    }
                    else
                    {
                        var orderLineModif = new OrderLine
                        {
                            id       = OrderLineOut.Id,
                            Product  = comboBoxProduit.SelectedItem as Product,
                            Quantity = Convert.ToInt32(textEditQuantité.EditValue.ToString())
                        };

                        var repositoryOrder = new RepositoryOrder();
                        repositoryOrder.Save(OrderLineOut.IdOrder, orderLineModif);
                        MessageBox.Show(Resources.succesUpdate);
                    }

                    IsOrderLineModified = false;
                }

                if (result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
        }
        /// <summary>
        /// Prints out a welcome message and the menu.
        /// Then creates a customer item, allows the user to select a store and pizza.
        /// The order is then saved to a file/db
        /// </summary>
        private static void Run()
        {
            var order = new Order();

            order.Customer = new Customer();

            WelcomeUser();
            Console.WriteLine("\nAre you a...");
            Console.WriteLine("1 - Customer");
            Console.WriteLine("2 - Store Manager");

            int tempInput;
            int options;

            do
            {
                tempInput = SafeUserInput();
            } while (tempInput <= 0 || tempInput > 2);

            if (tempInput == 1)
            {
                Console.WriteLine("\nEnter your name:");
                order.Customer.Name = Console.ReadLine();
                order.Store         = SelectStore();
                order.Pizza.Add(SelectPizza());

                do
                {
                    DisplayOrder(order);

                    do
                    {
                        options = 0;
                        Console.WriteLine("Do you want to...");
                        Console.WriteLine($"{++options} - Add another pizza to  your order");
                        Console.WriteLine($"{++options} - Remove a pizza from  your order");
                        Console.WriteLine($"{++options} - Finalize your order");
                        tempInput = SafeUserInput();
                    } while (tempInput <= 0 || tempInput > options);

                    switch (tempInput)
                    {
                    case 1:
                        order.Pizza.Add(SelectPizza());
                        break;

                    case 2:
                        RemovePizza(order);
                        break;

                    case 3:
                        break;

                    default:
                        Console.WriteLine("Something went wrong");
                        break;
                    }
                } while (tempInput != options);


                using (var tempContext = new PizzaDbContext())
                {
                    RepositoryOrder repositoryOrder = new RepositoryOrder(DbContextSingleton.Instance.Context);
                    repositoryOrder.Add(order);
                }
                order.Save();
            }
            else
            {
                var store = SelectStore();

                do
                {
                    options = 0;
                    Console.WriteLine("Do you want to...");
                    Console.WriteLine($"{++options} - View order history");
                    Console.WriteLine($"{++options} - View order history for a specific customer");
                    Console.WriteLine($"{++options} - View the sales report");
                    tempInput = SafeUserInput();
                } while (tempInput <= 0 || tempInput > options);

                using (var tempContext = new PizzaDbContext())
                {
                    RepositoryOrder repositoryOrder = new RepositoryOrder(DbContextSingleton.Instance.Context);
                    List <Order>    orders          = repositoryOrder.GetList();

                    int     index        = 0;
                    string  customerName = "";
                    decimal revenue      = 0;

                    if (tempInput == 2)
                    {
                        customerName = Console.ReadLine();
                    }

                    StringBuilder buffer = new StringBuilder();
                    foreach (var item in orders)
                    {
                        if (item.Store.Name == store.Name)
                        {
                            switch (tempInput)
                            {
                            case 1:
                                buffer.AppendLine($"\n{++index}:\n{item}");
                                buffer.AppendLine($"Customer name: {item.Customer.Name}\n");
                                break;

                            case 2:
                                if (item.Customer.Name.Equals(customerName))
                                {
                                    buffer.AppendLine($"{++index}:\n{item}");
                                    buffer.AppendLine($"Customer name: {item.Customer.Name}\n");
                                }
                                break;

                            case 3:
                                buffer.AppendLine($"\n{++index}:\n{item}");
                                buffer.AppendLine($"Customer name: {item.Customer.Name}\n");
                                revenue += item.priceTotal;
                                break;

                            default:
                                Console.WriteLine("Something went wrong");
                                break;
                            }
                        }
                    }
                    Console.WriteLine(buffer.ToString());

                    if (tempInput == 3)
                    {
                        Console.WriteLine($"Total revenue: ${revenue}");
                    }
                }
            }
        }
        public string CreateReceipt(ModelViewUserG objCred, ModelViewReceiptRef obj)
        {
            var objRepository   = new RepositoryOrder();
            var NegocioOrden    = new BusinessOrder();
            var objAlerta       = new BusinessNotification();
            var NegocioUsuario  = new BusinessUsers();
            var NegocioCliente  = new BusinessClient();
            var NegocioContrato = new BusinessContrat();
            var NegocioEmpleado = new BusinessEmployee();
            var NegocioBOM      = new BusinessBuildOfMaterial();

            var dataUsuario = NegocioUsuario.GetUserByToken(objCred.TokenUser);

            if (objCred.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (objCred.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }
            if (dataUsuario == null)
            {
                throw new Exception("UserPasswordInvalid");
            }


            var empleado = NegocioEmpleado.GetByUserID(dataUsuario.UserID);
            var orden    = NegocioOrden.GetByOrderID(obj.FK_OrderID);
            var cliente  = NegocioCliente.GetByID(orden.FK_ClientID);


            SpreadsheetInfo.SetLicense("EQU2-3K5L-UZDC-SDYN");
            string         Origin = GlobalConfiguration.MabeAttachmentsLocal + "FormatoReciboRef.xlsx";
            List <string>  result = obj.EMails.Split(new char[] { ';' }).ToList();
            ExcelFile      ef     = ExcelFile.Load(Origin);
            ExcelWorksheet ws     = ef.Worksheets[0];


            ws.Cells["W9"].Value  = obj.Folio;
            ws.Cells["W12"].Value = DateTime.Today.ToString("dd-MM-yyyy");
            ws.Cells["L18"].Value = cliente.FirstName.ToUpper();
            ws.Cells["P18"].Value = cliente.LastName.ToUpper();
            ws.Cells["L21"].Value = cliente.PhoneNumber1;
            ws.Cells["T21"].Value = cliente.PhoneNumber2;
            ws.Cells["M23"].Value = cliente.Email;


            int cantidad = 29;


            foreach (var jko in obj.SpareParts)
            {
                if (cantidad == 60)
                {
                    cantidad = 85;
                }
                ////var bom = NegocioBOM.GetByID(jko.ProductID);
                //if (bom != null)
                //{
                //    ws.Cells["L" + cantidad1.ToString()].Value = bom.SparePartsID;
                //    ws.Cells["L" + cantidad.ToString()].Value = bom.SparePartDescription;
                //}
                else
                {
                    ws.Cells["K" + cantidad.ToString()].Value = jko.RefManID;
                    ws.Cells["M" + cantidad.ToString()].Value = jko.SparePartsDescription;
                }
                ws.Cells["R" + cantidad.ToString()].Value = jko.Quantity;
                ws.Cells["U" + cantidad.ToString()].Value = Convert.ToDouble(jko.Price);
                ws.Cells["W" + cantidad.ToString()].Value = Convert.ToDouble(jko.Totals);
                cantidad = cantidad + 1;
            }

            double subtotal    = Convert.ToDouble(obj.SubTotal);
            double iva         = Convert.ToDouble(obj.IVA);
            double total       = Convert.ToDouble(obj.Total);
            double subtotalref = subtotal;
            string totalletras = NegocioOrden.enletras(total.ToString());

            ws.Cells["W41"].Value = subtotalref;

            ws.Cells["W42"].Value = iva;
            ws.Cells["W43"].Value = total;

            string file    = "ReciboRef" + obj.Folio + ".pdf";
            string quotion = "RecibosRefaccion_" + DateTime.Today.ToString("yyyyMMdd");
            string Destiny = GlobalConfiguration.MabeAttachmentsLocal + quotion + "/" + file;

            if (obj.SpareParts.Count < 11)
            {
                ws.NamedRanges.SetPrintArea(ws.Cells.GetSubrange("J1", "X54"));
            }
            string Cotizaciones = new DirectoryInfo(GlobalConfiguration.MabeAttachmentsLocal).ToString() + quotion;

            if (!(Directory.Exists(Cotizaciones)))
            {
                Directory.CreateDirectory(Cotizaciones);
            }
            ef.Save(Destiny);
            string URL    = GlobalConfiguration.urlRequest + "Content/Attachments/" + quotion + "/" + file;
            var    Recibo = NegocioContrato.GetByOrderFolio(orden.PK_OrderID, obj.Folio);



            if (obj.EMails != "")
            {
                if (Recibo == null)
                {
                    Recibo = NegocioContrato.Insert(orden.PK_OrderID, obj.Folio, URL);
                }
                else
                {
                    Recibo.Fk_OrderID = orden.PK_OrderID;
                    Recibo.Folio      = obj.Folio;
                    Recibo.Ruta       = URL;
                    NegocioContrato.Update(Recibo);
                }

                string sb = File.ReadAllText(GlobalConfiguration.LocateBodyMail + "MaiReciboRef.txt");
                sb = sb.Replace("#%Nombre%#", cliente.FirstName + " " + cliente.LastName);
                sb = sb.Replace("#%Folio%#", obj.Folio);

                objAlerta.SendMailExchange(GlobalConfiguration.exchangeUserCotiza, GlobalConfiguration.exchangePwdCotiza, result, "Recibo Refacciones", sb.ToString(), Destiny);
                return(URL);
            }
            else
            {
                string Tipo     = "Recibo";
                var    EnvioSMS = SendNotification(obj.PhoneNumber, Tipo, URL);

                return(EnvioSMS);
            }
        }
        public string SetRefQuotation(ModelViewUserG objCred, ModelViewBilling obj)
        {
            var objRepository            = new RepositoryOrder();
            var NegocioOrden             = new BusinessOrder();
            var objAlerta                = new BusinessNotification();
            var NegocioUsuario           = new BusinessUsers();
            var NegocioCliente           = new BusinessClient();
            var NegocioBase              = new BusinessInstalledBase();
            var NegocioProducto          = new BusinessProduct();
            var NegocioFallas            = new BusinessCodeFailure();
            var NegocioBOM               = new BusinessBuildOfMaterial();
            var NegocioCotizacion        = new BusinessQuotation();
            var NegocioCotizacionDetalle = new BusinessRefsellDetail();
            var NegocioCFP               = new BusinessCodeFailureByProduct();
            var NegocioCF                = new BusinessCodeFailure();
            var NegocioLugarCompra       = new BusinessShopPlace();
            var NegocioEmpleado          = new BusinessEmployee();
            var NegocioMonitor           = new BusinessVisit();
            var NegocioHistorico         = new BusinessHistory();
            var NegocioGarantia          = new BusinessGuaranty();
            var NegocioPayment           = new BusinessPayment();
            var NegocioInvoice           = new BusinessInvoice();
            var NegocioRefsell           = new BusinessRefsell();
            var dataUsuario              = NegocioUsuario.GetUserByToken(objCred.TokenUser);

            if (objCred.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (objCred.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }
            if (dataUsuario == null)
            {
                throw new Exception("UserPasswordInvalid");
            }

            var empleado = NegocioEmpleado.GetByUserID(dataUsuario.UserID);
            var orden    = NegocioOrden.GetByOrderID(obj.ODS);


            var cliente = NegocioCliente.GetByID(orden.FK_ClientID);

            var lugarcompra = NegocioLugarCompra.GetByShopPlaceID(obj.FK_ShopPlaceID.Value);
            var pro         = NegocioProducto.GetByID(obj.FK_ProductID.Value);

            SpreadsheetInfo.SetLicense("EQU2-3K5L-UZDC-SDYN");
            string         Origin = GlobalConfiguration.MabeAttachmentsLocal + "FormatoVentaRefacciones.xlsx";
            List <string>  result = obj.EMails.Split(new char[] { ';' }).ToList();
            ExcelFile      ef     = ExcelFile.Load(Origin);
            ExcelWorksheet ws     = ef.Worksheets[0];
            string         Folio  = "";

            ws.Cells["L7"].Value  = obj.ODS;
            ws.Cells["L9"].Value  = cliente.ClientID;
            ws.Cells["L11"].Value = cliente.FirstName.ToUpper() + " " + cliente.LastName.ToUpper();
            ws.Cells["L13"].Value = pro.Model + " / " + pro.ProductName.ToUpper();
            ws.Cells["U13"].Value = DateTime.Today.ToString("dd-MM-yyyy");

            ws.Cells["L80"].Value = obj.ODS;
            int cantidad  = 30;
            int cantidad1 = 31;

            foreach (var jko in obj.BillingDetails)
            {
                if (jko.SparePartsDescription.EndsWith("-R"))
                {
                    Folio = jko.SparePartsDescription;
                    ws.Cells["L6"].Value  = Folio;
                    ws.Cells["L79"].Value = Folio;
                }
                else
                {
                    if (cantidad == 60)
                    {
                        cantidad  = 85;
                        cantidad1 = 86;
                    }
                    var bom = NegocioBOM.GetByID(jko.ProductID);
                    if (bom != null)
                    {
                        ws.Cells["L" + cantidad1.ToString()].Value = bom.SparePartsID;
                        ws.Cells["L" + cantidad.ToString()].Value  = bom.SparePartDescription;
                    }
                    else
                    {
                        ws.Cells["L" + cantidad1.ToString()].Value = jko.RefManID;
                        ws.Cells["L" + cantidad.ToString()].Value  = jko.SparePartsDescription;
                    }
                    ws.Cells["J" + cantidad.ToString()].Value = jko.Quantity;
                    ws.Cells["T" + cantidad.ToString()].Value = Convert.ToDouble(jko.Price);
                    ws.Cells["V" + cantidad.ToString()].Value = Convert.ToDouble(jko.Totals);
                    cantidad  = cantidad + 3;
                    cantidad1 = cantidad1 + 3;
                }
            }

            double subtotal    = Convert.ToDouble(obj.SubTotal.Substring(1));
            double iva         = Convert.ToDouble(obj.IVA.Substring(1));
            double total       = Convert.ToDouble(obj.Total.Substring(1));
            double subtotalref = subtotal;
            string totalletras = NegocioOrden.enletras(total.ToString());

            ws.Cells["M16"].Value = subtotalref;
            ws.Cells["M17"].Value = subtotal;
            ws.Cells["M18"].Value = iva;
            ws.Cells["U17"].Value = total;
            ws.Cells["M19"].Value = totalletras;
            string file    = "Cotización_" + Folio + ".pdf";
            string quotion = "CotizacionesRefaccion_" + DateTime.Today.ToString("yyyyMMdd");
            string Destiny = GlobalConfiguration.MabeAttachmentsLocal + quotion + "/" + file;

            if (obj.BillingDetails.Count < 11)
            {
                ws.NamedRanges.SetPrintArea(ws.Cells.GetSubrange("J1", "W74"));
            }
            string Cotizaciones = new DirectoryInfo(GlobalConfiguration.MabeAttachmentsLocal).ToString() + quotion;

            if (!(Directory.Exists(Cotizaciones)))
            {
                Directory.CreateDirectory(Cotizaciones);
            }
            ef.Save(Destiny);
            string URL        = GlobalConfiguration.urlRequest + "Content/Attachments/" + quotion + "/" + file;
            var    cotizacion = NegocioCotizacion.GetByOrderFolio(orden.PK_OrderID, Folio);
            var    Payment    = NegocioPayment.GetPolicyPayment(orden.PK_OrderID, Folio);
            var    Invoice    = NegocioInvoice.GetPolicyInvoice(orden.PK_OrderID, Folio);


            var LsVenta = NegocioRefsell.GetByFolio(orden.PK_OrderID, Folio);

            if (obj.EMails != "")
            {
                if (cotizacion == null)
                {
                    cotizacion = NegocioCotizacion.Insert(orden.PK_OrderID, subtotal.ToString(), iva.ToString(), total.ToString(), Folio, URL, obj.EstimatedTipe, empleado[0].PK_EmployeeID);
                }
                else
                {
                    cotizacion.Folio         = Folio;
                    cotizacion.IVA           = iva.ToString();
                    cotizacion.SubTotal      = subtotal.ToString();
                    cotizacion.Total         = total.ToString();
                    cotizacion.URL           = URL;
                    cotizacion.ModifyDate    = DateTime.UtcNow;
                    cotizacion.TypeQuotation = obj.EstimatedTipe;
                    cotizacion.FK_EmployeeID = empleado[0].PK_EmployeeID;
                    NegocioCotizacion.Update(cotizacion);
                }

                string sb     = File.ReadAllText(GlobalConfiguration.LocateBodyMail + "NotificationCotizacion.txt");
                string lugCom = obj.ShopDate != null ? obj.ShopDate : "";
                sb = sb.Replace("#%Nombre%#", cliente.FirstName + " " + cliente.LastName);
                sb = sb.Replace("#%OrderID%#", obj.ODS);
                sb = sb.Replace("#%Folio%#", Folio);
                sb = sb.Replace("#%Modelo%#", pro.Model);
                sb = sb.Replace("#%Descripcion%#", pro.ProductName.ToUpper());
                sb = sb.Replace("#%Serie%#", obj.SerialNumber);
                sb = sb.Replace("#%Fecha%#", lugCom);
                sb = sb.Replace("#%Lugar%#", lugarcompra.ShopPlace1);
                //objAlerta.SendMails(result, "Cotización ServiPlus", sb.ToString(), Destiny);
                objAlerta.SendMailExchange(GlobalConfiguration.exchangeUserCotiza, GlobalConfiguration.exchangePwdCotiza, result, "Cotización ServiPlus", sb.ToString(), Destiny);
            }
            else
            {
                if (LsVenta.PK_RefSellID == 0)
                {
                    if (cotizacion == null)
                    {
                        cotizacion = NegocioCotizacion.Insert(orden.PK_OrderID, subtotal.ToString(), iva.ToString(), total.ToString(), Folio, URL, obj.EstimatedTipe, empleado[0].PK_EmployeeID);
                    }
                    else
                    {
                        cotizacion.Folio         = Folio;
                        cotizacion.IVA           = iva.ToString();
                        cotizacion.SubTotal      = subtotal.ToString();
                        cotizacion.Total         = total.ToString();
                        cotizacion.URL           = URL;
                        cotizacion.ModifyDate    = DateTime.UtcNow;
                        cotizacion.TypeQuotation = obj.EstimatedTipe;
                        cotizacion.FK_EmployeeID = empleado[0].PK_EmployeeID;
                        NegocioCotizacion.Update(cotizacion);
                    }
                    var NewRefSell = new EntityRefSell();
                    var NuevaVenta = new EntityRefSell();

                    NewRefSell.FK_OrderID     = orden.PK_OrderID;
                    NewRefSell.FK_ClientID    = cliente.PK_ClientID;
                    NewRefSell.FK_EmployeeID  = empleado[0].PK_EmployeeID;
                    NewRefSell.FK_PaymentID   = Payment.PK_PaymentID;
                    NewRefSell.FK_Invoice_ID  = Invoice.InvoicingID;
                    NewRefSell.FK_ProductID   = obj.FK_ProductID.Value;
                    NewRefSell.FK_ShopPlace   = obj.FK_ShopPlaceID.Value;
                    NewRefSell.FK_QuotationID = cotizacion.PK_QuotationID;
                    NewRefSell.IDRefSell      = Folio;
                    NuevaVenta = NegocioRefsell.Insert(NewRefSell);
                }
                else
                {
                    LsVenta.FK_OrderID     = orden.PK_OrderID;
                    LsVenta.FK_ClientID    = cliente.PK_ClientID;
                    LsVenta.FK_EmployeeID  = empleado[0].PK_EmployeeID;
                    LsVenta.FK_PaymentID   = Payment.PK_PaymentID;
                    LsVenta.FK_Invoice_ID  = Invoice.InvoicingID;
                    LsVenta.FK_QuotationID = LsVenta.FK_QuotationID;
                    LsVenta.FK_ProductID   = obj.FK_ProductID.Value;
                    LsVenta.FK_ShopPlace   = obj.FK_ShopPlaceID.Value;

                    NegocioRefsell.Update(LsVenta);

                    if (cotizacion == null)
                    {
                        cotizacion = NegocioCotizacion.Insert(orden.PK_OrderID, subtotal.ToString(), iva.ToString(), total.ToString(), Folio, URL, obj.EstimatedTipe, empleado[0].PK_EmployeeID);
                    }
                    else
                    {
                        cotizacion.Folio         = Folio;
                        cotizacion.IVA           = iva.ToString();
                        cotizacion.SubTotal      = subtotal.ToString();
                        cotizacion.Total         = total.ToString();
                        cotizacion.URL           = URL;
                        cotizacion.ModifyDate    = DateTime.UtcNow;
                        cotizacion.TypeQuotation = obj.EstimatedTipe;
                        cotizacion.FK_EmployeeID = empleado[0].PK_EmployeeID;
                        NegocioCotizacion.Update(cotizacion);
                    }
                }
                string[] lstADR = { "T002", "T012", "T024" };

                foreach (var jko in obj.BillingDetails)
                {
                    string ADRAnt   = "";
                    int    ADRCount = 0;
                    bool   AddFlete = false;

                    if (jko.SparePartsDescription != Folio)
                    {
                        switch (jko.SparePartsDescription)
                        {
                        case "Fletes":
                        {
                            var DetailCotation2 = NegocioCotizacionDetalle.GetList(cotizacion.PK_QuotationID);

                            foreach (var items in DetailCotation2)
                            {
                                if (lstADR.Contains(items.Origen))
                                {
                                    if (ADRAnt != items.Origen)
                                    {
                                        ADRAnt = items.Origen;
                                        ADRCount++;
                                        if (ADRCount < 3)
                                        {
                                            AddFlete = true;
                                        }
                                        else
                                        {
                                            AddFlete = false;
                                        }
                                    }
                                    if (AddFlete)
                                    {
                                        items.Flete      = true;
                                        items.CostoFlete = jko.Price;
                                        NegocioCotizacionDetalle.Update(items);
                                        AddFlete = false;
                                    }
                                }
                            }
                        }

                        break;

                        default:
                            var newDetailquotion = NegocioCotizacionDetalle.GetDetail(cotizacion.PK_QuotationID, jko.ProductID);

                            if (newDetailquotion == null)
                            {
                                NegocioCotizacionDetalle.Insert(cotizacion.PK_QuotationID, jko.ProductID, jko.Quantity.ToString(), jko.RefManID, jko.Origins, jko.Price);
                            }
                            break;
                        }
                    }
                }


                var Refacciones = new BusinessMabe().Orden_Venta(obj.ODS, obj.ServiceTypes, Folio);
            }
            return(obj.ODS);
        }
Esempio n. 17
0
        public ActionResult CreateReservation(ReservationMD Data)
        {
            DBOperationResult result = RepositoryOrder.Insert(Data);

            return(Json(result));
        }
Esempio n. 18
0
 public RepositoryConnection Repositories(int?first = null, string after = null, int?last = null, string before = null, RepositoryPrivacy?privacy = null, RepositoryOrder orderBy = null, IQueryable <RepositoryAffiliation?> affiliations = null, bool?isLocked = null, bool?isFork = null) => this.CreateMethodCall(x => x.Repositories(first, after, last, before, privacy, orderBy, affiliations, isLocked, isFork), Octokit.GraphQL.RepositoryConnection.Create);