Beispiel #1
0
        private void AddProductButton_Click(object sender, EventArgs e)
        {
            AddProducts AddProducts = new AddProducts(this);

            AddProducts.AddNewProduct += AddProducts_AddNewProduct;
            AddProducts.Show();
        }
        private void go_add(object sender, RoutedEventArgs e)
        {
            AddProducts add = new AddProducts();

            this.Close();
            add.Show();
        }
Beispiel #3
0
        private void LoadDgvDetails()
        {
            string token = Session.Token;

            var idPurchaseRequest = Session.id;

            lblIDProcesoVenta.Visible = true;
            lblIDProcesoVenta.Text    = Session.id;

            // lblNSolicitudCompra.Text = _loginData.id;

            var findByIdPurchaseRequest = VirtualFairIntegration.FindByIdPurchaseRequest(token, idPurchaseRequest);

            List <AddProducts> lstSalesProcessesDetails = new List <AddProducts>();

            if (findByIdPurchaseRequest.countRows != 0)
            {
                foreach (var item in findByIdPurchaseRequest.purchaseRequestProducts)
                {
                    AddProducts pRobject = new AddProducts();
                    pRobject.nameProduct = item.product.name.ToString();
                    pRobject.weight      = item.weight;
                    pRobject.nameClient  = item.purchaseRequest.client.fullName.ToString();

                    lstSalesProcessesDetails.Add(pRobject);
                }

                lblNombreUsuario.Text = lstSalesProcessesDetails[0].nameClient.ToString();
                lblDate.Text          = String.Concat("Finalizado el ", Session.date);
            }

            dgvDetails.AutoGenerateColumns = false;

            dgvDetails.DataSource = lstSalesProcessesDetails;

            string[] arrayString = new string[] { "nameProduct", "weight" };

            //List<PropertyInfo> lst = typeof(AdminApi).GetProperties().Where(x => x.Name == "id" || x.Name == "fullName" ||
            //                                                                x.Name == "email" || x.Name == "nameProfile" ).ToList();

            foreach (var item in arrayString)
            {
                DataGridViewTextBoxColumn dataGrid = new DataGridViewTextBoxColumn();

                dataGrid.DataPropertyName = item;
                if (item == "nameProduct")
                {
                    dataGrid.HeaderText = "Nombre producto";
                }
                if (item == "weight")
                {
                    dataGrid.HeaderText = "Peso Kg";
                }

                dataGrid.Name = item;

                dgvDetails.Columns.Add(dataGrid);
            }
        }
        private void LoadDgvParticipants()
        {
            string token = Session.Token;

            dynamic parameters = new System.Dynamic.ExpandoObject();

            parameters.idPurchaseRequest = Session.id;

            var getFindByIdPurchaseRequest = VirtualFairIntegration.GetFindByIdPurchaseRequest(token, parameters);
            //GetFindByIdPurchaseRequest

            List <string> lstNamesProducts = new List <string>();

            List <AddProducts> lstSalesProcessesDetails = new List <AddProducts>();
            List <AddProducts> lstAddProducts           = new List <AddProducts>();

            if (getFindByIdPurchaseRequest.countRows != 0)
            {
                foreach (var item in getFindByIdPurchaseRequest.purchaseRequestProducers)
                {
                    AddProducts pRobject = new AddProducts();
                    pRobject.nameClient  = item.producer.fullName;
                    pRobject.nameProduct = item.purchaseRequestProduct.product.name;

                    lstSalesProcessesDetails.Add(pRobject);
                    //lstNamesProducts.Add(item.product.name.ToString());
                }
            }

            dgvParticipants.AutoGenerateColumns = false;

            //var productsElements = from element in lstSalesProcessesDetails where

            dgvParticipants.DataSource = lstSalesProcessesDetails;

            string[] arrayString = new string[] { "nameClient", "nameProduct" };

            foreach (var item in arrayString)
            {
                DataGridViewTextBoxColumn dataGrid = new DataGridViewTextBoxColumn();

                dataGrid.DataPropertyName = item;
                dataGrid.ReadOnly         = true;

                if (item == "nameClient")
                {
                    dataGrid.HeaderText = "Nombre participante";
                }
                if (item == "nameProduct")
                {
                    dataGrid.HeaderText = "Nombre producto";
                }

                dataGrid.Name = item;

                dgvParticipants.Columns.Add(dataGrid);
            }
        }
Beispiel #5
0
        protected void AddProductButton_Click(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Add")
            {
                Page.Validate("Add");
            }

            Boolean fileOK = false;
            String  path   = Server.MapPath("~/Catalog/Images/");

            if (ProductImage.HasFile)
            {
                String   fileExtension     = System.IO.Path.GetExtension(ProductImage.FileName).ToLower();
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        fileOK = true;
                    }
                }
            }

            if (fileOK)
            {
                try
                {
                    // Save to Images folder.
                    ProductImage.PostedFile.SaveAs(path + ProductImage.FileName);
                    // Save to Images/Thumbs folder.
                    ProductImage.PostedFile.SaveAs(path + "Thumbs/" + ProductImage.FileName);
                }
                catch (Exception ex)
                {
                    LabelAddStatus.Text = ex.Message;
                }

                // Add product data to DB.
                AddProducts products   = new AddProducts();
                bool        addSuccess = products.AddProduct(AddProductName.Text, AddProductDescription.Text,
                                                             AddProductPrice.Text, DropDownAddCategory.SelectedValue, ProductImage.FileName);
                if (addSuccess)
                {
                    // Reload the page.
                    string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                    Response.Redirect(pageUrl + "?ProductAction=add");
                }
                else
                {
                    LabelAddStatus.Text = "Unable to add new product to database.";
                }
            }
            else
            {
                LabelAddStatus.Text = "Unable to accept file type.";
            }
        }
Beispiel #6
0
 private void MainGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (_currentTable.Equals(db.Orders.GetType()))
     {
         if (e.ColumnIndex == 1)
         {
             AddMenuPoint VeiwMenuPointForm = new AddMenuPoint(
                 db.Menu.Find
                     (MainGrid.CurrentCell.Value)
                 , this, true);
             VeiwMenuPointForm.Show();
         }
         if (e.ColumnIndex == 2)
         {
             AddChef VeiwChefForm = new AddChef(
                 db.Chefs.Find
                     (MainGrid.CurrentCell.Value)
                 , true);
             VeiwChefForm.Show();
         }
     }
     if (_currentTable.Equals(db.Menu.GetType()))
     {
         if (e.ColumnIndex == 2)
         {
             int          no = (int)MainGrid.CurrentCell.Value;
             AddReception VeiwReceptionForm = new AddReception(
                 db.Receptions.Where
                     (recept => recept.No == no).ToList()
                 , this, true);
             VeiwReceptionForm.Show();
         }
     }
     if (_currentTable.Equals(db.Receptions.GetType()))
     {
         if (e.ColumnIndex == 1)
         {
             AddProducts VeiwProductFrom = new AddProducts(
                 db.Products.Single
                     (item => item.Id.ToString().Equals(MainGrid.CurrentCell.Value.ToString()))
                 , true);
             VeiwProductFrom.Show();
         }
     }
     if (_currentTable.Equals(db.Cheks.GetType()))
     {
         if (e.ColumnIndex == 1)
         {
             AddOrder VeiwOrderForm = new AddOrder(
                 db.Orders.Single
                     (item => item.Id == (int)MainGrid.CurrentCell.Value)
                 , this, true);
             VeiwOrderForm.Show();
         }
     }
 }
Beispiel #7
0
        protected void AddProductBtn_Click(object sender, EventArgs e)
        {
            bool fileOk = false;
            string path = Server.MapPath("~/Catalog/Images/");
            if (ProductImage.HasFile)
            {
                string uploadedFileExt = Path.GetExtension(ProductImage.FileName).ToLower();
                string[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };

                fileOk = allowedExtensions.Any(ext => ext == uploadedFileExt);
            }

            if (!fileOk)
            {
                AlertBox.Attributes.Add("class", AlertBox.Attributes["class"].Replace("alert-success", "alert-danger"));
                AlertBox.Visible = true;
                LabelAlertStatus.Text = "Unable to accept file type.";
                return;
            }
            else
            {
                try
                {
                    // Save to Images folder.
                    ProductImage.PostedFile.SaveAs(path + ProductImage.FileName);
                    // Save to Images/Thumb folder.
                    ProductImage.PostedFile.SaveAs(path + "Thumbs/" + ProductImage.FileName);
                }
                catch(Exception ex)
                {
                    AlertBox.Attributes.Add("class", AlertBox.Attributes["class"].Replace("alert-success", "alert-danger"));
                    AlertBox.Visible = true;
                    LabelAlertStatus.Text = ex.Message;
                }

                // Add product data to DB.
                AddProducts products = new AddProducts();
                bool addSuccess = products.AddProduct(
                    AddProductName.Text, AddProductDescription.Text, AddProductPrice.Text,
                    DropDownAddCategory.SelectedValue, ProductImage.FileName
                );
                if(!addSuccess)
                {
                    AlertBox.Attributes.Add("class", AlertBox.Attributes["class"].Replace("alert-success", "alert-danger"));
                    AlertBox.Visible = true;
                    LabelAlertStatus.Text = "Unable to add new product to database.";
                    return;
                }
                else
                {
                    Response.Redirect($"{GetPageUrl()}?ProductAction=add");
                }
            }
        }
Beispiel #8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            View        view        = new View();
            Productos   products    = new Productos();
            Cart        cart        = new Cart();
            AddProducts addProducts = new AddProducts(view);
            Presenter   presenter   = new Presenter(view, products, cart);

            Application.Run(view);
        }
        // Kada se klikne na AddProductButton, kod proverava HasFile svojstvo kontrole FileUpload.
        //Ako kontrola ima datoteku i ako je dozvoljen tip datoteke (na osnovu ekstenzije datoteke), slika se čuva u \
        //folderu Slike i folderu Images / Thumbs aplikacije.
        protected void AddProductButton_Click(object sender, EventArgs e)
        {
            Boolean fileOK = false;
            String  path   = Server.MapPath("~/Catalog/Images/");

            if (ProductImage.HasFile)
            {
                String   fileExtension     = System.IO.Path.GetExtension(ProductImage.FileName).ToLower();
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        fileOK = true;
                    }
                }
            }

            if (fileOK)
            {
                try
                {
                    // Save to Images folder.
                    ProductImage.PostedFile.SaveAs(path + ProductImage.FileName);
                    // Save to Images/Thumbs folder.
                    ProductImage.PostedFile.SaveAs(path + "Thumbs/" + ProductImage.FileName);
                }
                catch (Exception ex)
                {
                    LabelAddStatus.Text = ex.Message;
                }

                // Add product data to DB.
                AddProducts products   = new AddProducts();
                bool        addSuccess = products.AddProduct(AddProductName.Text, AddProductDescription.Text,
                                                             AddProductPrice.Text, DropDownAddCategory.SelectedValue, ProductImage.FileName);
                if (addSuccess)
                {
                    // Ponovo ucitajte stranicu.
                    string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                    Response.Redirect(pageUrl + "?ProductAction=add");
                }
                else
                {
                    LabelAddStatus.Text = "Nije moguce dodati novi proizvod u bazu podataka";
                }
            }
            else
            {
                LabelAddStatus.Text = "Nije moguce prihvatiti tip datoteke.";
            }
        }
Beispiel #10
0
        protected void AddProductButton_Click(object sender, EventArgs e)
        {
            Boolean fOK  = false;
            String  path = Server.MapPath("~/Catalog/Images/");

            if (ProductImage.HasFile)
            {
                String   fileExtension     = System.IO.Path.GetExtension(ProductImage.FileName).ToLower();
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        fOK = true;
                    }
                }
            }

            if (fOK)
            {
                try
                {
                    // Zapis obraz
                    ProductImage.PostedFile.SaveAs(path + ProductImage.FileName);
                    // Zapis miniaturę obrazu.
                    ProductImage.PostedFile.SaveAs(path + "Thumbs/" + ProductImage.FileName);
                }
                catch (Exception ex)
                {
                    LabelAddStatus.Text = ex.Message;
                }

                // Dodaj produkt do bazy danych DB.
                AddProducts products   = new AddProducts();
                bool        addSuccess = products.AddProduct(AddProductName.Text, AddProductDescription.Text,
                                                             AddProductPrice.Text, DropDownAddCategory.SelectedValue, ProductImage.FileName);
                if (addSuccess)
                {
                    // Przeładuj stronę.
                    string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                    Response.Redirect(pageUrl + "?ProductAction=add");
                }
                else
                {
                    LabelAddStatus.Text = "Nie udało się dodać produktu do bazy danych.";
                }
            }
            else
            {
                LabelAddStatus.Text = "Zły fomat pliku z zdjeciem, użyj: .gif, .png, .jpeg, .jpg .";
            }
        }
Beispiel #11
0
        protected void AddProductButton_Click(object sender, EventArgs e)
        {
            var fileOk = false;
            var path   = Server.MapPath("~/Catalog/Images/");

            if (ProductImage.HasFile)
            {
                var      fileExtension     = Path.GetExtension(ProductImage.FileName).ToLower();
                string[] allowedExtensions = { ".gif", ".png", ".jpg", ".jpeg" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        fileOk = true;
                    }
                }
            }
            if (fileOk)
            {
                try {
                    // Save to Images folder
                    ProductImage.PostedFile.SaveAs(path + ProductImage.FileName);
                    // Save to Images/Thumbs folder.
                    ProductImage.PostedFile.SaveAs($"{path}Thumbs/{ProductImage.FileName}");
                } catch (Exception ex) {
                    LabelAddStatus.Text = ex.Message;
                }

                // Add product data to db
                var products   = new AddProducts();
                var addSuccess = products.AddProduct(AddProductName.Text, AddProductDescription.Text, AddProductPrice.Text, ddlAddCategory.SelectedValue, ProductImage.FileName);
                if (addSuccess)
                {
                    // Reload the page
                    var pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                    Response.Redirect($"{pageUrl}?ProductAction=add");
                }
                else
                {
                    LabelAddStatus.Text = "Unable to add new product to database";
                }
            }
            else
            {
                LabelAddStatus.Text = "Unable to accept file type";
            }
        }
        private void btnAgregarSolicitud_Click(object sender, EventArgs e)
        {
            var peso           = nudPesoKg.Value;
            var idProducto     = cmbProducts.SelectedValue.ToString();
            var nombreProducto = cmbProducts.Text;
            var comentario     = txtComentario.Text;
            var refri          = chkRequiereRefrigeracion.Checked;

            var refriValue = refri ? 1 : 0;

            var refrigeracion = refri ? "Si" : "No";

            if (nombreProducto != "")
            {
                AddProducts products = new AddProducts();

                products.idProduct   = Convert.ToInt32(idProducto);
                products.nameProduct = nombreProducto;
                products.weight      = Convert.ToInt32(peso);
                products.remark      = comentario;
                products.requieresRefrigerationBool = refriValue;
                products.requiresRefrigeration      = refrigeracion;


                items.Add(products);

                var filenamesList = new BindingList <AddProducts>(items);

                dgvProducts1.DataSource = filenamesList;

                dgvProducts1.Update();
                dgvProducts1.Refresh();


                txtComentario.Text = "";
                nudPesoKg.Value    = 0;
                chkRequiereRefrigeracion.Checked = false;
            }
            else
            {
                string text  = "Se deben completar todos los campos requeridos";
                string title = "Información";
                MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #13
0
        private void btnAgregarSolicitud_Click(object sender, EventArgs e)
        {
            var peso           = nudPesoKg.Value;
            int idProducto     = Convert.ToInt32(cmbProducts.SelectedValue.ToString());
            var nombreProducto = cmbProducts.Text;
            var comentario     = txtComentario.Text;
            var refri          = chkRequiereRefrigeracion.Checked;

            var refriValue = refri ? 1 : 0;

            var refrigeracion = refri ? "Si" : "No";

            var filenamesList = new BindingList <AddProducts>(items);

            if (filenamesList.Where(x => x.idProduct == idProducto).FirstOrDefault() == null)
            {
                AddProducts products = new AddProducts();

                products.idProduct   = Convert.ToInt32(idProducto);
                products.nameProduct = nombreProducto;
                products.weight      = Convert.ToInt32(peso);
                products.remark      = comentario;
                products.requieresRefrigerationBool = refriValue;
                products.requiresRefrigeration      = refrigeracion;

                items.Add(products);

                dgvProducts1.DataSource = filenamesList;

                dgvProducts1.Update();
                dgvProducts1.Refresh();

                txtComentario.Text = "";
                nudPesoKg.Value    = 0;
                chkRequiereRefrigeracion.Checked = false;
            }
            else
            {
                string text  = "No se puede agregar dos veces el mismo producto, favor eliminar y volver a agregar.";
                string title = "Información";
                MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        protected void AddProductButton_Click(object sender, EventArgs e)
        {
            string path = Server.MapPath("~/Catalog/Images/");

            if (ProductImage.HasFile)
            {
                string   fileExtension     = System.IO.Path.GetExtension(ProductImage.FileName).ToLower();
                string[] allowedextensions = { ".gif", ".png", ".jpeg", ".jpg" };
                if (allowedextensions.Contains(fileExtension))
                {
                    try
                    {
                        ProductImage.PostedFile.SaveAs(path + ProductImage.FileName);
                        ProductImage.PostedFile.SaveAs(path + "Thumbs/" + ProductImage.FileName);
                    }
                    catch (Exception ex)
                    {
                        LabelAddStatus.Text = ex.Message;
                    }
                }
            }
            else
            {
                LabelAddStatus.Text = "Unable to accept file type.";
            }

            AddProducts products = new AddProducts();

            bool addSuccess = products.AddProduct(AddProductName.Text, AddProductDescription.Text, AddProductPrice.Text, DropDownAddCategory.SelectedValue, ProductImage.FileName);

            if (addSuccess)
            {
                string pageUrl = Request.Url.AbsoluteUri.Substring(0,
                                                                   Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                Response.Redirect(pageUrl + "?ProductAction=add");
            }
            else
            {
                LabelAddStatus.Text = "Unable to add new product to database.";
            }
        }
 private void addProduct_btn_Click(object sender, EventArgs e)
 {
     this.addProductsForm = new AddProducts();
     FormsUI.LoadChildForm(this, this.addProductsForm, ChildNastedLevel.NastedNastedNasted, this.addProduct_btn);
 }
        private void LoadDgvSP()
        {
            string token = Session.Token;

            var idPurchaseRequest = Session.id;

            // lblNSolicitudCompra.Text = _loginData.id;

            var findByIdPurchaseRequest = VirtualFairIntegration.FindByIdPurchaseRequest(token, idPurchaseRequest);

            List <string> lstNamesProducts = new List <string>();

            List <AddProducts> lstSalesProcessesDetails = new List <AddProducts>();

            if (findByIdPurchaseRequest.countRows != 0)
            {
                lblFechaDecision.Visible = true;
                lblFechaDecision.Text    = findByIdPurchaseRequest.purchaseRequestProducts[0].purchaseRequest.desiredDate;
                lblStatus.Visible        = true;
                lblStatus.Text           = findByIdPurchaseRequest.purchaseRequestProducts[0].purchaseRequest.purchaseRequestStatus.name.ToString();

                //if (lblStatus.Text == "ACEPTADO POR EL CLIENTE")
                //{
                //    lblParticipando.Text = "Eres el Ganador";
                //}

                foreach (var item in findByIdPurchaseRequest.purchaseRequestProducts)
                {
                    AddProducts pRobject = new AddProducts();
                    pRobject.idPurchaseRequestProduct = item.id;
                    pRobject.nameProduct = item.product.name.ToString();
                    pRobject.weight      = item.weight;

                    lstSalesProcessesDetails.Add(pRobject);
                    lstNamesProducts.Add(item.product.name.ToString());
                }
            }

            Session.lstNamesProducts = lstNamesProducts;
            Session.countRows        = findByIdPurchaseRequest.countRows;
            Session.lstAddProducts   = lstSalesProcessesDetails;

            dgvDetails.AutoGenerateColumns = false;

            dgvDetails.DataSource = lstSalesProcessesDetails;

            string[] arrayString = new string[] { "nameProduct", "weight" };

            //List<PropertyInfo> lst = typeof(AdminApi).GetProperties().Where(x => x.Name == "id" || x.Name == "fullName" ||
            //                                                                x.Name == "email" || x.Name == "nameProfile" ).ToList();

            foreach (var item in arrayString)
            {
                DataGridViewTextBoxColumn dataGrid = new DataGridViewTextBoxColumn();

                dataGrid.DataPropertyName = item;
                dataGrid.ReadOnly         = true;

                if (item == "nameProduct")
                {
                    dataGrid.HeaderText = "Nombre producto";
                }
                if (item == "weight")
                {
                    dataGrid.HeaderText = "Peso Kg";
                }

                dataGrid.Name = item;

                dgvDetails.Columns.Add(dataGrid);
            }
        }
 public ManageCalims(IWebDriver driver) : base(driver)
 {
     _driver     = driver;
     _addProduct = new AddProducts(_driver);
 }
Beispiel #18
0
        private void ChangeRecordBTN_Click(object sender, EventArgs e)
        {
            List <Form> changeForm = new List <Form>();

            if (_currentTable.Equals(db.Orders.GetType()) && !db.Orders.Find(MainGrid.CurrentRow.Cells[0].Value).State)
            {
                AddOrder ChangeOrderForm = new AddOrder(db.Orders.Find(MainGrid.CurrentRow.Cells[0].Value), this);
                changeForm.Add(ChangeOrderForm);
                ChangeOrderForm.ShowDialog();
                if (ChangeOrderForm.flag)
                {
                    db.Orders.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).DishID = ChangeOrderForm.DishID;
                    db.Orders.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).ChefId = ChangeOrderForm.Chef;
                    db.Orders.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).State  = ChangeOrderForm.state;
                }
            }
            if (_currentTable.Equals(db.Chefs.GetType()))
            {
                AddChef ChangeChefForm = new AddChef(db.Chefs.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value));
                changeForm.Add(ChangeChefForm);
                ChangeChefForm.ShowDialog();
                if (ChangeChefForm.flag)
                {
                    db.Chefs.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).Name          = ChangeChefForm.name;
                    db.Chefs.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).Surname       = ChangeChefForm.surname;
                    db.Chefs.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).Salary        = ChangeChefForm.salary;
                    db.Chefs.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).Birthday      = ChangeChefForm.birthday;
                    db.Chefs.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).Pozition_name = ChangeChefForm.pozition;
                }
            }
            if (_currentTable.Equals(db.Products.GetType()))
            {
                AddProducts ChangeProductForm = new AddProducts(db.Products.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value));
                changeForm.Add(ChangeProductForm);
                ChangeProductForm.ShowDialog();
                if (ChangeProductForm.flag)
                {
                    db.Products.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).ProductName = ChangeProductForm.ProdName;
                    db.Products.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).Type        = ChangeProductForm.Type;
                    db.Products.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).Count       = ChangeProductForm.Count;
                }
            }
            if (_currentTable.Equals(db.Menu.GetType()))
            {
                AddMenuPoint ChangeMenuPointForm = new AddMenuPoint(db.Menu.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value), this);
                ChangeMenuPointForm.ShowDialog();
                if (ChangeMenuPointForm.flag)
                {
                    db.Menu.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).DishName        = ChangeMenuPointForm.DishName;
                    db.Menu.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).Cost            = ChangeMenuPointForm.Cost;
                    db.Menu.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).ReceptionID     = ChangeMenuPointForm.ReceptionID;
                    db.Menu.ToList().Find(item => item.Id == (int)MainGrid.CurrentRow.Cells[0].Value).WaitingTime_Min = ChangeMenuPointForm.WTime;
                }
            }
            if (_currentTable.Equals(db.Receptions.GetType()))
            {
                int          no = Int32.Parse(MainGrid.CurrentRow.Cells[0].Value.ToString());
                AddReception ChangeReceptionForm = new AddReception(
                    db.Receptions.Where
                        (recept => recept.No == no).ToList()
                    , this);
                changeForm.Add(ChangeReceptionForm);
                ChangeReceptionForm.ShowDialog();
                if (ChangeReceptionForm.flag)
                {
                    db.Receptions.RemoveRange(db.Receptions.Where(recept => recept.No == no).ToList());
                    db.SaveChanges();
                    db.Receptions.AddRange(ChangeReceptionForm.ReceptionList);
                }
            }
            if (_currentTable.Equals(db.Cheks.GetType()))
            {
                int     no = Int32.Parse(MainGrid.CurrentRow.Cells[0].Value.ToString());
                AddChek ChangeCheckFrom = new AddChek(this, db.Cheks.Where(item => item.Id == no).ToList());
                changeForm.Add(ChangeCheckFrom);
                ChangeCheckFrom.ShowDialog();
                if (ChangeCheckFrom.flag && ChangeCheckFrom.ChekList != null)
                {
                    db.Cheks.AddRange(ChangeCheckFrom.ChekList);
                }
            }
            try
            {
                db.SaveChanges();
                foreach (Form item in changeForm)
                {
                    item.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Refresh_Grid();
        }
Beispiel #19
0
        private void addProductsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var form = new AddProducts(UpdateDataGridWiew);

            form.ShowDialog();
        }
Beispiel #20
0
        private void AddProducts(object obj)
        {
            AddProducts addWindow = new AddProducts();

            addWindow.Show();
        }
Beispiel #21
0
        private void LoadDetails()
        {
            string token = Session.Token;

            var idPurchaseRequest = Session.id;

            // lblNSolicitudCompra.Text = _loginData.id;

            var findByIdPurchaseRequest = VirtualFairIntegration.FindByIdPurchaseRequest(token, idPurchaseRequest);

            if (findByIdPurchaseRequest.statusCode == 403)
            {
                string text  = findByIdPurchaseRequest.message;
                string title = "Información";
                MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information);

                var login = new Login();
                login.Show();

                this.Close();
            }
            else if (true)
            {
            }

            List <string> lstNamesProducts = new List <string>();

            List <AddProducts> lstSalesProcessesDetails = new List <AddProducts>();

            if (findByIdPurchaseRequest.countRows != 0)
            {
                lblFechaDecision.Visible = true;
                lblFechaDecision.Text    = findByIdPurchaseRequest.purchaseRequestProducts[0].purchaseRequest.desiredDate.ToString();

                foreach (var item in findByIdPurchaseRequest.purchaseRequestProducts)
                {
                    AddProducts pRobject = new AddProducts();
                    pRobject.nameProduct = item.product.name.ToString();
                    pRobject.weight      = item.weight;

                    lstSalesProcessesDetails.Add(pRobject);
                    lstNamesProducts.Add(item.product.name.ToString());
                }
            }

            Session.lstNamesProducts = lstNamesProducts;
            Session.countRows        = findByIdPurchaseRequest.countRows;


            dgvDetails.AutoGenerateColumns = false;

            dgvDetails.DataSource = lstSalesProcessesDetails;

            string[] arrayString = new string[] { "nameProduct", "weight" };

            //List<PropertyInfo> lst = typeof(AdminApi).GetProperties().Where(x => x.Name == "id" || x.Name == "fullName" ||
            //                                                                x.Name == "email" || x.Name == "nameProfile" ).ToList();

            foreach (var item in arrayString)
            {
                DataGridViewTextBoxColumn dataGrid = new DataGridViewTextBoxColumn();

                dataGrid.DataPropertyName = item;
                dataGrid.ReadOnly         = true;

                if (item == "nameProduct")
                {
                    dataGrid.HeaderText = "Nombre producto";
                }
                if (item == "weight")
                {
                    dataGrid.HeaderText = "Peso Kg";
                }

                dataGrid.Name = item;

                dgvDetails.Columns.Add(dataGrid);
            }
        }
Beispiel #22
0
        private void btnProducts_Click(object sender, RoutedEventArgs e)
        {
            AddProducts addProd = new AddProducts(this, lstProductModel, ifEdit);

            addProd.ShowDialog();
        }
Beispiel #23
0
        protected void UpdateProductButton_Click(object sender, EventArgs e)
        {
            Boolean fileOK = false;
            String  path   = Server.MapPath("~/Catalog/Images/");

            if (UpdateFileUpload.HasFile)
            {
                String   fileExtension     = System.IO.Path.GetExtension(UpdateFileUpload.FileName).ToLower();
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        fileOK = true;
                    }
                }
            }

            if (fileOK)
            {
                try
                {
                    // Save to Images folder.
                    UpdateFileUpload.PostedFile.SaveAs(path + UpdateFileUpload.FileName);
                    // Save to Images/Thumbs folder.
                    UpdateFileUpload.PostedFile.SaveAs(path + "Thumbs/" + UpdateFileUpload.FileName);
                }
                catch (Exception ex)
                {
                    LabelAddStatus.Text = ex.Message;
                }

                // Add product data to DB.
                AddProducts products   = new AddProducts();
                var         ID         = Convert.ToInt16(DropDownRemoveProduct.SelectedValue);
                bool        addSuccess = false;
                using (var db = new ApplicationDbContext())
                {
                    if (db.Products.Any(p => p.ProductID == ID))
                    {
                        addSuccess = products.AddProduct(UpdateNameTextBox.Text, UpdateDescriptionTextBox.Text,
                                                         UpdatePriceTextBox.Text, UpdateCategoryDropDownList.SelectedValue, UpdateFileUpload.FileName, ID);
                    }
                    else
                    {
                        addSuccess = products.AddProduct(UpdateNameTextBox.Text, UpdateDescriptionTextBox.Text,
                                                         UpdatePriceTextBox.Text, UpdateCategoryDropDownList.SelectedValue, UpdateFileUpload.FileName);
                    }
                }

                if (addSuccess)
                {
                    // Reload the page.
                    Session["OutcomeMessage"] = ID == 0 ? "Added new product " + UpdateNameTextBox.Text : "Updated product " + UpdateNameTextBox.Text;
                    string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                    Response.Redirect(pageUrl /*+ "?ProductAction=add"*/);
                }
                else
                {
                    LabelAddStatus.Text = "Unable to add new product to database.";
                }
            }
            else
            {
                LabelAddStatus.Text = "Unable to accept file type.";
            }
        }
        public PurchaseRequestDetails(PurchaseRequestDTO loginData)
        {
            _loginData = loginData;
            InitializeComponent();

            var nameUser    = Session.NameUser;
            var nameProfile = Session.NameProfile;

            lblBienvenido.Text = String.Concat("Bienvenido ", nameUser, " | ", nameProfile.ToUpper());

            string token             = Session.Token;
            string idPurchaseRequest = _loginData.id;

            lblNSolicitudCompra.Text = _loginData.id;

            var findByIdPurchaseRequest = VirtualFairIntegration.FindByIdPurchaseRequest(token, idPurchaseRequest);



            List <AddProducts> listPurchaseRequestDetials = new List <AddProducts>();

            if (findByIdPurchaseRequest.countRows != 0)
            {
                lblEstado.Text      = String.Concat("Estado: ", findByIdPurchaseRequest.purchaseRequestProducts[0].purchaseRequest.purchaseRequestStatus.name);
                lblDesiredDate.Text = String.Concat("Fecha desea de entrega: ", findByIdPurchaseRequest.purchaseRequestProducts[0].purchaseRequest.desiredDate);

                foreach (var item in findByIdPurchaseRequest.purchaseRequestProducts)
                {
                    AddProducts pRobject = new AddProducts();
                    pRobject.nameProduct = item.product.name.ToString();
                    pRobject.weight      = item.weight;
                    //pRobject.idPurchaseRequestType = purchaseRequest.purchaseRequests[0].idPurchaseRequestType.ToString();
                    pRobject.remark = item.remark.ToString();
                    pRobject.requieresRefrigerationBool = item.requiresRefrigeration;

                    if (pRobject.requieresRefrigerationBool == 1)
                    {
                        pRobject.requiresRefrigeration = "Si";
                    }
                    else if (pRobject.requieresRefrigerationBool == 0)
                    {
                        pRobject.requiresRefrigeration = "No";
                    }


                    pRobject.agreedPrice = item.agreedPrice.ToString();

                    listPurchaseRequestDetials.Add(pRobject);
                }
            }



            dgvPurchaseRequestDetails.AutoGenerateColumns = false;

            dgvPurchaseRequestDetails.DataSource = listPurchaseRequestDetials;

            string[] arrayString = new string[] { "nameProduct", "weight", "remark", "requiresRefrigeration", "agreedPrice" };

            //List<PropertyInfo> lst = typeof(AdminApi).GetProperties().Where(x => x.Name == "id" || x.Name == "fullName" ||
            //                                                                x.Name == "email" || x.Name == "nameProfile" ).ToList();

            foreach (var item in arrayString)
            {
                DataGridViewTextBoxColumn dataGrid = new DataGridViewTextBoxColumn();

                dataGrid.DataPropertyName = item;
                if (item == "nameProduct")
                {
                    dataGrid.HeaderText = "Nombre producto";
                }
                if (item == "weight")
                {
                    dataGrid.HeaderText = "Peso Kg";
                }
                else if (item == "remark")
                {
                    dataGrid.HeaderText = "Comentario";
                }
                else if (item == "requiresRefrigeration")
                {
                    dataGrid.HeaderText = "Requiere refrigeración";
                }
                else if (item == "agreedPrice")
                {
                    dataGrid.HeaderText = "Precio acordado";
                }

                dataGrid.Name = item;

                dgvPurchaseRequestDetails.Columns.Add(dataGrid);
            }
        }
        private void btnAgregarSolicitud_Click(object sender, EventArgs e)
        {
            if (cmbProducts.Items.Count == 0)
            {
                string text  = "No existen productos para comprar.";
                string title = "Información";
                MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.Close();

                var purchaseRequestExternal = new PurchaseRequest();
                purchaseRequestExternal.Show();
            }
            else
            {
                var peso = nudPesoKg.Value;
                int idPurchaseRequest = Convert.ToInt32(cmbProducts.SelectedValue.ToString());
                var nombreProducto    = cmbProducts.Text;
                //var comentario = txtComentario.Text;
                var refri = chkRequiereRefrigeracion.Checked;

                var refriValue = refri ? 1 : 0;

                var refrigeracion = refri ? "Si" : "No";

                var pr          = nombreProducto.Split('$');
                var pr1         = pr[1].Split(' ');
                var precioFinal = pr1[0];

                var filenamesList = new BindingList <AddProducts>(items);

                // var asdf1 = filenamesList.Where(x=> x.id == )

                if (filenamesList.Where(x => x.idProduct == idPurchaseRequest).FirstOrDefault() == null)
                {
                    AddProducts products = new AddProducts();

                    for (int z = 0; z <= Session.lstProducts.Count - 1; z++)
                    {
                        if (Session.lstProducts.Where(x => x.id == Session.lstProducts[z].id).First().id == idPurchaseRequest)
                        {
                            products.idProduct = Session.lstProducts.Where(x => x.id == Session.lstProducts[z].id).First().idProduct;
                        }
                    }

                    decimal precio = (peso * Convert.ToInt32(precioFinal));

                    products.id = Convert.ToInt32(idPurchaseRequest);
                    //products.idProduct = Convert.ToInt32(idProducto);
                    products.nameProduct = nombreProducto;
                    products.weight      = Convert.ToInt32(peso);
                    products.price       = Convert.ToString(precio);
                    products.requieresRefrigerationBool = refriValue;
                    products.requiresRefrigeration      = refrigeracion;

                    items.Add(products);

                    dgvProducts.DataSource = filenamesList;

                    dgvProducts.Update();
                    dgvProducts.Refresh();

                    nudPesoKg.Value = 0;
                    chkRequiereRefrigeracion.Checked = false;
                }
                else
                {
                    string text  = "No se puede agregar dos veces el mismo producto, favor eliminar y volver a agregar.";
                    string title = "Información";
                    MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        //Servicio para obtener una lista de la participación del productor que estan participando en la solicitud de compra por IdPurchaseRequest y por IdProducer
        private void LoadDgvParticipating()
        {
            string token = Session.Token;

            dynamic parameters = new System.Dynamic.ExpandoObject();

            parameters.idPurchaseRequest = Session.id;
            parameters.idProducer        = Session.IdProfile;

            var findByIdPurchaseRequestAndIdProducer = VirtualFairIntegration.FindByIdPurchaseRequestAndIdProducer(token, parameters);

            List <string> lstNamesProducts = new List <string>();

            List <AddProducts> lstSalesProcessesDetails = new List <AddProducts>();
            List <AddProducts> lstAddProducts           = new List <AddProducts>();

            if (findByIdPurchaseRequestAndIdProducer.countRows != 0)
            {
                foreach (var item in findByIdPurchaseRequestAndIdProducer.purchaseRequestProducers)
                {
                    AddProducts pRobject = new AddProducts();
                    pRobject.idPurchaseRequestProduct = item.idPurchaseRequestProduct;
                    pRobject.nameProduct = item.purchaseRequestProduct.product.name;
                    pRobject.weight      = item.weight;
                    pRobject.price       = item.price.ToString();

                    lstSalesProcessesDetails.Add(pRobject);
                    //lstNamesProducts.Add(item.product.name.ToString());
                }
            }

            Session.lstNamesProducts = lstNamesProducts;

            lstAddProducts = Session.lstAddProducts;

            List <AddProducts> orderList = lstSalesProcessesDetails.OrderBy(x => x.idPurchaseRequestProduct).ToList();


            dgvParticipating.AutoGenerateColumns = false;


            //var productsElements = from element in lstSalesProcessesDetails where

            dgvParticipating.DataSource = orderList;

            string[] arrayString = new string[] { "weight", "price" };

            //List<PropertyInfo> lst = typeof(AdminApi).GetProperties().Where(x => x.Name == "id" || x.Name == "fullName" ||
            //                                                                x.Name == "email" || x.Name == "nameProfile" ).ToList();

            foreach (var item in arrayString)
            {
                DataGridViewTextBoxColumn dataGrid = new DataGridViewTextBoxColumn();

                dataGrid.DataPropertyName = item;
                dataGrid.ReadOnly         = true;

                if (item == "weight")
                {
                    dataGrid.HeaderText = "Peso ofrecido Kg";
                }
                if (item == "price")
                {
                    dataGrid.HeaderText = "$ Valor por Kg";
                }

                dataGrid.Name = item;

                dgvParticipating.Columns.Add(dataGrid);
            }
        }
Beispiel #27
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            if (_currentTable.Equals(db.Orders.GetType()))
            {
                AddOrder AddOrderForm = new AddOrder(this);
                AddOrderForm.ShowDialog();
                if (AddOrderForm.flag)
                {
                    try
                    {
                        Orders new_order = new Orders {
                            DishID = AddOrderForm.DishID,
                            ChefId = AddOrderForm.Chef,
                            Time   = AddOrderForm.time,
                            State  = AddOrderForm.state
                        };
                        db.Orders.Add(new_order);
                        db.SaveChanges();
                        AddOrderForm.Dispose();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            if (_currentTable.Equals(db.Chefs.GetType()))
            {
                AddChef AddChefForm = new AddChef();
                AddChefForm.ShowDialog();
                if (AddChefForm.flag)
                {
                    try
                    {
                        Chef new_chef = new Chef {
                            Name          = AddChefForm.name,
                            Surname       = AddChefForm.surname,
                            Salary        = AddChefForm.salary,
                            Birthday      = AddChefForm.birthday,
                            Pozition_name = AddChefForm.pozition
                        };
                        db.Chefs.Add(new_chef);
                        db.SaveChanges();
                        AddChefForm.Dispose();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            if (_currentTable.Equals(db.Products.GetType()))
            {
                AddProducts AddProductForm = new AddProducts();
                AddProductForm.ShowDialog();
                if (AddProductForm.flag)
                {
                    try
                    {
                        Products new_product = new Products {
                            ProductName = AddProductForm.ProdName,
                            Count       = AddProductForm.Count,
                            Type        = AddProductForm.Type
                        };
                        db.Products.Add(new_product);
                        db.SaveChanges();
                        AddProductForm.Dispose();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            if (_currentTable.Equals(db.Menu.GetType()))
            {
                AddMenuPoint AddMenuPointForm = new AddMenuPoint(this);
                AddMenuPointForm.ShowDialog();
                if (AddMenuPointForm.flag)
                {
                    try
                    {
                        Classes.Menu new_menu = new Classes.Menu {
                            DishName        = AddMenuPointForm.DishName,
                            ReceptionID     = AddMenuPointForm.ReceptionID,
                            Cost            = AddMenuPointForm.Cost,
                            WaitingTime_Min = AddMenuPointForm.WTime
                        };
                        db.Menu.Add(new_menu);
                        db.SaveChanges();
                        AddMenuPointForm.Dispose();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            if (_currentTable.Equals(db.Receptions.GetType()))
            {
                AddReception AddReceptionForm = new AddReception(this);
                AddReceptionForm.ShowDialog();
                if (AddReceptionForm.flag)
                {
                    try
                    {
                        db.Receptions.AddRange(AddReceptionForm.ReceptionList);
                        db.SaveChanges();
                        AddReceptionForm.Dispose();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            if (_currentTable.Equals(db.Cheks.GetType()))
            {
                AddChek AddCheckForm = new AddChek(this);
                AddCheckForm.ShowDialog();
                if (AddCheckForm.flag)
                {
                    db.Cheks.AddRange(AddCheckForm.ChekList);
                    foreach (var CurrentOrder in AddCheckForm.ChosenOrder)
                    {
                        db.Orders.Find(CurrentOrder.Id).State = true;
                    }
                    foreach (var CurrentDish in AddCheckForm.ChosenDish)
                    {
                        foreach (var CurrentReception in db.Receptions.Where(item => item.No == CurrentDish.ReceptionID).ToList())
                        {
                            db.Products.ToList().Find(item => item.Id == CurrentReception.ProductId).Count -= CurrentReception.Count;
                        }
                    }
                    db.SaveChanges();
                    AddCheckForm.Dispose();
                }
            }

            Refresh_Grid();
        }
        protected void orderButton_Click(object sender, EventArgs e)
        {
            double total = 0.0;

            string size, crust, sauce;
            string topping = "";


            if (smallButton.Checked)
            {
                total = 10.0;
                size  = "Size :Small,";
            }
            else if (mediumButton.Checked)
            {
                total = 13.0;
                size  = "Size :Medium,";
            }

            else
            {
                total = 16.0;
                size  = "Size :Large,";
            }


            if (regularButton.Checked)
            {
                total += 2.0;
                crust  = "Crust :Regular,";
            }

            else if (thinButton.Checked)
            {
                total += 4.0;
                crust  = "Crust :Thin,";
            }

            else
            {
                total += 6.0;
                crust  = "Crust :Thick,";
            }

            if (bbqButton.Checked)
            {
                total += 2.0;
                sauce  = "BBQ,";
            }
            else
            {
                total += 1.75;
                sauce  = "Pesto,";
            }

            List <String> toppingList = new List <string>();

            foreach (ListItem item in CheckBoxList1.Items)
            {
                if (item.Selected)
                {
                    toppingList.Add(item.Value);
                    topping += item.Value + ",";
                    total   += 2.0;
                }
            }

            /*      if (pepperoniCheckbox.Checked)
             *    {
             *        total += 1.5;
             *        topping += "Pepperoni,";
             *    }
             *    else if (hamCheckbox.Checked)
             *    {
             *        total += 2.0;
             *        topping += "Ham,";
             *    }
             *    else if (freshgarlicCheckbox.Checked)
             *    {
             *        total += 0.75;
             *        topping += "Fresh Garlic,";
             *    }
             *    else if (onionCheckbox.Checked)
             *    {
             *        total += 0.75;
             *        topping += "Onion";
             *    }
             *    else if (mushroomCheckbox.Checked)
             *    {
             *        total += 0.75;
             *        topping += "Mushroom,";
             *    }
             *    else if (baconCheckbox.Checked)
             *    {
             *        total += 2.0;
             *        topping += "Bacon,";
             *    }
             *    else if (sausageCheckbox.Checked)
             *    {
             *        total += 1.5;
             *        topping += "Sausage";
             *
             *    }*/


            /* total = (pepperoniCheckbox.Checked) ? total + 1.5 : total;
             * total = (hamCheckbox.Checked) ? total + 2.0 : total;
             * total = (greenpepperCheckbox.Checked) ? total + 0.75 : total;
             * total = (freshgarlicCheckbox.Checked) ? total + 1.5 : total;
             * total = (onionCheckbox.Checked) ? total + 0.75 : total;
             * total = (mushroomCheckbox.Checked) ? total + 0.75 : total;
             * total = (baconCheckbox.Checked) ? total + 2.0 : total;
             * total = (sausageCheckbox.Checked) ? total + 1.5 : total;*/

            resultTotal.Text = total.ToString();
            resulttext.Text  = ("Size :" + size + "Crust :" + crust + "Sauce :" + sauce + "Topping :" + topping).ToString();
            Label1.Text      = "6";
            Label2.Text      = "pizzahotdog.jpg";

            AddProducts products = new AddProducts();

            products.AddProduct("Special :" + foodname.Text, resulttext.Text, resultTotal.Text, Label1.Text, Label2.Text);
            Status.Text = "Your Own Food Create Successfully :)";
        }
Beispiel #29
0
 public Home()
 {
     InitializeComponent();
     ItemPage        = new ItemPage();
     addProductsPage = new AddProducts();
 }
Beispiel #30
0
        protected void updateProductName_ServerValidate(object sender, ServerValidateEventArgs e)
        {
            //String connectionString = @"Data Source=DESKTOP-S3P3TBM\SQLEXPRESS;Initial Catalog=wingtiptoys.mdf;Integrated Security=True";
            string connectionString = "Data Source=MYLAPTOP\\SQLEXPRESS;Database=wingtiptoys.mdf;Integrated Security=True";
            string queryString      = "SELECT * FROM dbo.Products WHERE ProductName = '" + DropDownUpdateProductName.SelectedItem.Text + "'";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                try
                {
                    if (reader.Read())
                    {
                        //update product record in database
                        e.IsValid = true;
                        System.Diagnostics.Debug.WriteLine(e.Value.ToString() + " Exists");
                        //update product in database
                        using (var _db = new WingtipToys.Models.ProductContext())
                        {
                            var myItem = (from c in _db.Products where c.ProductName == DropDownUpdateProductName.SelectedItem.Text select c).FirstOrDefault();
                            if (myItem != null)
                            {
                                System.Diagnostics.Debug.WriteLine(myItem.Description);
                                //remove product from database
                                _db.Products.Remove(myItem);
                                _db.SaveChanges();

                                // Add product data to DB.
                                AddProducts products = new AddProducts();
                                var         product  = new WingtipToys.Models.Product();
                                //update name, description, and price, but keep same category id and image file path for now
                                bool addSuccess = products.AddProduct(DropDownUpdateProductName.SelectedItem.Text, UpdateProductDescription.Text,
                                                                      UpdateProductPrice.Text, DropDownUpdateCategory.SelectedValue, myItem.ImagePath);
                                if (addSuccess)
                                {
                                    // Reload the page.
                                    string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                                    Response.Redirect(pageUrl + "?ProductAction=add");
                                }
                                else
                                {
                                    System.Diagnostics.Debug.WriteLine("Unable to add new product to database.");
                                }
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine("Unable to locate product.");
                            }
                        }
                    }
                    else
                    {
                        //Throw validation error because product does not exist and cannot be updated
                        e.IsValid = false;
                        System.Diagnostics.Debug.WriteLine(e.Value.ToString() + " Does not exist");
                    }
                }
                finally
                {
                    reader.Close();
                }
            }
        }