public ActionResult editporduct(int UpdateProductID)
        {
            ViewBag.list = Selectcategorise();
            products product = dbo.Getproduct(UpdateProductID);

            return(View(product));
        }
예제 #2
0
        //Edit products
        public void editProducts(products products)
        {
            SqlConnection connection = new SqlConnection(
                ConfigurationManager.ConnectionStrings["POS.Properties.Settings.Setting"].ConnectionString
                );

            try
            {
                connection.Open();
                string query = "UPDATE Product SET ProductName='" + products.ProductName + "'," +
                               "QuantityPerUnit=" + products.QuantityPerUnit + ",UnitPrice=" + products.UnitPrice + "," +
                               "UnitInStock=" + products.UnitInStock + ",ReorderLevel=" + products.ReorderLevel + " " +
                               " WHERE BarCode=" + products.BarCode + "";

                using (cmd = new SqlCommand(query, connection))
                {
                    cmd.ExecuteNonQuery();
                }
                connection.Close();
            }
            catch (Exception e)
            {
                e.ToString();
            }
        }
예제 #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {

            if (ProductID.Text == "" || ProductName.Text == "" || QuantityPerUnit.Text == "" || CategoryID.Text == "" ||
                UnitPrice.Text == "" || UnitInStock.Text == "" || ReorderLevel.Text == "" || SupplierID.Text == "" ||
                Discontinued.Text == "")
            {
                MessageBox.Show("All Fields are required to be filled");
            }
            else
            {
                dataAccess data = new dataAccess();
                products prod = new products();
                prod.BarCode = long.Parse(ProductID.Text);
                prod.ProductName = ProductName.Text;
                prod.QuantityPerUnit = int.Parse(QuantityPerUnit.Text);
                prod.ReorderLevel = int.Parse(ReorderLevel.Text);
                prod.UnitInStock = int.Parse(UnitInStock.Text);
                prod.UnitPrice = double.Parse(UnitPrice.Text);
                prod.Discontinued = Discontinued.Text;

                data.editProducts(prod);
                MessageBox.Show("Product " + prod.ProductName + " Modified Successfully");
            }
        }
예제 #4
0
        public async Task <IActionResult> Putproducts([FromRoute] string id, [FromBody] products products)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != products.productid)
            {
                return(BadRequest());
            }

            _context.Entry(products).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!productsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            int selectedIndex = productsDataGrid.CurrentCell.RowIndex;

            if (selectedIndex > -1)
            {
                string       productId          = productsDataGrid.Rows[selectedIndex].Cells[0].Value.ToString();
                string       productCode        = productsDataGrid.Rows[selectedIndex].Cells[1].Value.ToString();
                string       productName        = productsDataGrid.Rows[selectedIndex].Cells[2].Value.ToString();
                string       productMake        = productsDataGrid.Rows[selectedIndex].Cells[3].Value.ToString();
                string       productModel       = productsDataGrid.Rows[selectedIndex].Cells[4].Value.ToString();
                string       productDescription = productsDataGrid.Rows[selectedIndex].Cells[5].Value.ToString();
                string       productPrice       = productsDataGrid.Rows[selectedIndex].Cells[7].Value.ToString();
                string       quantity           = productsDataGrid.Rows[selectedIndex].Cells[8].Value.ToString();
                itemCategory itemCat            = (itemCategory)productsDataGrid.Rows[selectedIndex].Cells[9].Value;


                products selectedProduct = new products(int.Parse(productId), productCode, productName, productMake, productModel,
                                                        productDescription, decimal.Parse(productPrice), itemCat, int.Parse(quantity));

                stockDataManipulations stockDataManipulations = new stockDataManipulations();
                Boolean stockDeletion = stockDataManipulations.deleteProduct(selectedProduct);

                if (stockDeletion)
                {
                    MessageBox.Show("Deletion Successfull. Data deleted successfully", "Important Note",
                                    MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("Deletion Failed. Error occured while deleting data", "Important Note",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            }
        }
예제 #6
0
        public ActionResult Update(long id, String productName, Decimal price, String categoryId)
        {
            var rols = (byte[])Session["rols"];

            if (rols == null) //redirect to SinIn
            {
                return(RedirectToAction("Index", "Home"));
            }
            else if (rols.Contains <byte>(1))
            {
                var product = _products.GetOneById(id);
                product.productName = productName;
                product.price       = price;

                if (categoryId != "--Select--" && categoryId != "")
                {
                    product.categoryId = Int32.Parse(categoryId);
                }
                product.category = null;

                products newProducto = new products();
                newProducto.Update(product);

                return(RedirectToAction("Index"));
            }
            else//redirect to Home
            {
                return(RedirectToAction("Home", "Home"));
            }
        }
        private async void Btnagg_Clicked(object sender, EventArgs e)
        {
            btnagg.IsEnabled = false;
            products addfrentes = new products();

            addfrentes.cooler        = "/api/v1/coolers/" + Application.Current.Properties["uuidcooler"].ToString();
            addfrentes.audit         = "/api/v1/audits/" + Application.Current.Properties["idaudit"].ToString();
            addfrentes.product       = "/api/v1/products/" + uuidc.Text;
            addfrentes.quantity      = Convert.ToInt32(pickernofrentes.SelectedItem);
            addfrentes.singleBottles = Convert.ToInt32(pickernobotellas.SelectedItem);
            HttpClient    cliente = new HttpClient();
            var           Token   = Settings.token;
            var           json    = JsonConvert.SerializeObject(addfrentes);
            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
            var           token   = JsonConvert.SerializeObject(Token);

            cliente.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token);
            HttpResponseMessage response = await cliente.PostAsync("http://138.197.221.203/api/v1/fronts", content);

            string   result       = response.Content.ReadAsStringAsync().Result;
            Response responseData = JsonConvert.DeserializeObject <Response>(result);

            if (response.IsSuccessStatusCode)
            {
                App.Current.MainPage = new addfrentesandbotles();
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Opps algo ocuirrio mal!", "OK");

                App.Current.MainPage = new addfrentesandbotles();
            }
        }
예제 #8
0
        public ActionResult Create([FromBody] products product)
        {
            try
            {
                using (QuanLyBanHangEntities context = new QuanLyBanHangEntities())
                {
                    context.products.Add(product);
                    context.SaveChanges(); //id tự sinh
                }

                object result = new
                {
                    Code          = 201,
                    Message       = "Đã tạo product thành công!",
                    CreatedObject = product
                };
                return(Json(result));
            }
            catch (Exception ex)
            {
                object result = new
                {
                    Code    = 500,
                    Message = "Đã có lỗi xảy ra" + ex.Message
                };
                return(Json(result));
            }
        }
예제 #9
0
        public ActionResult Delete(int id)
        {
            try
            {
                using (QuanLyBanHangEntities context = new QuanLyBanHangEntities())
                {
                    products products = context.products.Find(id);
                    context.products.Remove(products);
                    context.SaveChanges();
                }

                object result = new
                {
                    Code    = 200,
                    Message = "Đã xoá product thành công!"
                };
                return(Json(result));
            }
            catch (Exception ex)
            {
                object result = new
                {
                    Code    = 500,
                    Message = "Đã có lỗi xảy ra" + ex.Message
                };
                return(Json(result));
            }
        }
예제 #10
0
        public int insertProduct(products tempProduct)
        {
            int result = 1;

            try
            {
                using (SqlConnection con = new SqlConnection(conString))
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("InsertProduct", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@prod_Code", tempProduct.ProductCode);
                    cmd.Parameters.AddWithValue("@prod_Name", tempProduct.ProductName);
                    cmd.Parameters.AddWithValue("@prod_Make", tempProduct.ProductMake);
                    cmd.Parameters.AddWithValue("@prod_Model", tempProduct.ProductModel);
                    cmd.Parameters.AddWithValue("@prod_Description", tempProduct.ProductDescription);
                    cmd.Parameters.AddWithValue("@prod_Price", tempProduct.ProductPrice);
                    cmd.Parameters.AddWithValue("@prod_Cat_ID", tempProduct.ProductCateogery.Item_Category_ID);
                    cmd.Parameters.AddWithValue("@quantity", tempProduct.Quantity);
                    result = (Int32)cmd.ExecuteScalar();
                    con.Close();
                }
            }
            catch (Exception e)
            {
                result = 0;
                logger.Error("DAL Error in insertProduct: " + e.Message);
                //Console.WriteLine("DAL Error in insertProduct: " + e.Message);
            }
            return(result);
        }
예제 #11
0
        public ActionResult About(products product)
        {
            repo.Addproducts(product);

            //ViewBag.Message = "Your application description page.";
            return(RedirectToAction("index"));
        }
예제 #12
0
        public ActionResult Create([FromBody] products products)
        {
            try
            {
                DataProvider.Ins.DB.products.Add(products);
                DataProvider.Ins.DB.SaveChanges();



                object result = new
                {
                    Code         = 200,
                    Message      = "Đã xoá products thành công",
                    CreateObject = products
                };

                return(Json(result));
            }
            catch (Exception ex)
            {
                object result = new
                {
                    Code    = 500,
                    Message = "Đã có lỗi xảy ra " + ex.Message
                };

                return(Json(result));
            }
        }
        public string Create(products Model)
        {
            DatabaseContext db = new DatabaseContext();
            string          msg;

            try
            {
                if (ModelState.IsValid)
                {
                    Model.idPromo = new Random().Next(1, 1000);
                    db.promo.Add(Model);
                    db.SaveChanges();
                    msg = "Saved Successfully";
                }
                else
                {
                    msg = "Validation data not successfully";
                }
            }
            catch (Exception ex)
            {
                msg = "Error occured:" + ex.Message;
            }
            return(msg);
        }
예제 #14
0
        protected void Add_To_Order()
        {
            var Product_id = GlobalVariables.JStoC_Product_ID;

            products = products.Select(Convert.ToInt32(Product_id));
            Response.Write("<script>alert('here is the results jimmy - " + products.product_name + " - " + products.product_id + " ' );</script>");
        }
예제 #15
0
        public string getFirstAvailableFromProductBarcode(ref int initialProductID)
        {
            string  barcodeString = "";
            Boolean available     = false;
            int     productCode   = initialProductID;

            while (available == false)
            {
                productCode.ToString("D5");
                barcodeString = gulsevenPrefix + productCode.ToString("D5");
                barcodeString = barcodeString + calcCheckDigit(barcodeString);

                products pModel = _context.Products.FirstOrDefault(x => x.productBarcodeID == barcodeString);
                if (pModel != null)
                {
                    productCode = productCode + 1;
                }
                else
                {
                    available = true;
                }
            }
            initialProductID = productCode;
            return(barcodeString);
        }
예제 #16
0
        public IHttpActionResult addItem([FromBody] itemsViewModel model)
        {
            var logInUserName = RequestContext.Principal.Identity.Name;

            try
            {
                if (model.is_Item_In_Store == "yes")
                {
                    if (model.product_name != null && model.catid != null && model.qtyAvailable >= 0 && model.qtyAvailable >= model.qtyReorderAlertValue)
                    {
                        var items = new products();
                        items.id                = "P-" + rd.Next(1000);
                        items.product_name      = model.product_name;
                        items.p_descripition    = model.desc;
                        items.serial_no         = model.serial_no;
                        items.cat_id            = model.catid;
                        items.opening_stock_qty = model.qtyAvailable;
                        items.item_base_unit    = model.item_base_unit;
                        items.total_item_allocated_pending_approval = 0;
                        items.current_stock_pending_approval        = items.opening_stock_qty - items.total_item_allocated_pending_approval;
                        items.stock_reorder_alert_qty = model.qtyReorderAlertValue;
                        items.unitPrice = model.unitPrice;
                        db.product.Add(items);
                        db.SaveChanges();
                        ulog.loguserActivities(logInUserName,
                                               "Added new item '" + items.product_name + "'");
                        return(Ok());
                    }
                }
                else
                {
                    if (model.product_name != null && model.catid != null && model.qtyReorderAlertValue >= 0)
                    {
                        var items = new products();
                        items.id                = "P-" + rd.Next(1000);
                        items.product_name      = model.product_name;
                        items.p_descripition    = model.desc;
                        items.serial_no         = model.serial_no;
                        items.cat_id            = model.catid;
                        items.opening_stock_qty = model.qtyAvailable;
                        items.item_base_unit    = model.item_base_unit;
                        items.total_item_allocated_pending_approval = 0;
                        items.current_stock_pending_approval        = items.opening_stock_qty - items.total_item_allocated_pending_approval;
                        items.stock_reorder_alert_qty = model.qtyReorderAlertValue;
                        items.unitPrice = model.unitPrice;
                        db.product.Add(items);
                        db.SaveChanges();
                        ulog.loguserActivities(logInUserName,
                                               "Added new item '" + items.product_name + "'");
                        return(Ok());
                    }
                }

                return(Content(HttpStatusCode.NotAcceptable, "Some items field are wrongly filled"));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.BadRequest, ex));
            }
        }
예제 #17
0
        public HttpResponseMessage createProduct(products product)
        {
            var endpoint = urlProducts;
            //products p = new products {Name = product.Name, Description = product.Description, Amount = product.Amount, DestinationCity = product.DestinationCity, EventDate=product.EventDate, TransportType = product.TransportType, PeopleNumber = product.PeopleNumber, OriginCity = product.OriginCity, File = product.File };
            var client = new HttpClient();

            var file = product.File;


            var fileStreamContent = new StreamContent(file.OpenReadStream());

            fileStreamContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(file.ContentType);


            var multiContent = new MultipartFormDataContent
            {
                { new StringContent(product.Name), "Name" },
                { new StringContent(product.Description), "Description" },
                { new StringContent(Convert.ToString(product.Amount)), "Amount" },
                { new StringContent(product.DestinationCity), "DestinationCity" },
                { new StringContent(product.EventDateString), "EventDateString" },
                { new StringContent(product.TransportType), "TransportType" },
                { new StringContent(Convert.ToString(product.PeopleNumber)), "PeopleNumber" },
                { new StringContent(product.OriginCity), "OriginCity" },
            };


            multiContent.Add(fileStreamContent, "FileImage", file.Name);
            var response = client.PostAsync(endpoint, multiContent).Result;

            client.Dispose();
            return(response);
        }
예제 #18
0
        public async Task <ActionResult> Create1(products Obj)
        {
            int d = Obj.Cid;

            Response.Write(d);
            return(View("Create", Obj));
        }
예제 #19
0
        public ActionResult Create(
            [Bind(Include = "id,product_code,product_name,description,standard_cost,list_price,target_level,reorder_level,minimum_reorder_quantity,quantity_per_unit,discontinued,category,image")] products products,
            HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                // Xử lý file: lưu file vào thư mục UploadedFiles/ProductImages
                string _FileName = "";
                // Di chuyển file vào thư mục mong muốn
                if (image != null && image.ContentLength > 0)
                {
                    _FileName = Path.GetFileName(image.FileName);                   // QRCode_NenTangUrl.png
                    string _FileNameExtension = Path.GetExtension(image.FileName);  // .png
                    if ((_FileNameExtension == ".png" ||
                         _FileNameExtension == ".jpg" ||
                         _FileNameExtension == ".jpeg"
                         ) == false)
                    {
                        return(View(String.Format("File có đuôi {0} không được chấp nhận. Vui lòng kiểm tra lại!", _FileNameExtension)));
                    }

                    // Upload file lên thư mục Web Server (VPS)
                    string uploadFolderPath = Server.MapPath("~/UploadedFiles/ProductImages");
                    if (Directory.Exists(uploadFolderPath) == false) // Nếu thư mục cần lưu trữ file upload không tồn tại (chưa có) => Tạo mới
                    {
                        Directory.CreateDirectory(uploadFolderPath);
                    }

                    // Copy file ảnh vào Thư mục UploadFiles/ProductImages trên Server
                    //string _path = Path.Combine(uploadFolderPath, _FileName);
                    //image.SaveAs(_path);

                    // Lưu thông tin đường dẫn vào Database
                    products.image = image.FileName;

                    // Update file lên thư mục Storage Azure
                    // Create Reference to Azure Storage Account
                    String strorageconn            = this.StorageConnectionString;
                    CloudStorageAccount storageacc = CloudStorageAccount.Parse(strorageconn);

                    //Create Reference to Azure Blob
                    CloudBlobClient blobClient = storageacc.CreateCloudBlobClient();

                    //The next 2 lines create if not exists a container named "democontainer"
                    CloudBlobContainer container = blobClient.GetContainerReference("democontainer");
                    container.CreateIfNotExists();

                    //The next 7 lines upload the file test.txt with the name DemoBlob on the container "democontainer"
                    CloudBlockBlob blockBlob = container.GetBlockBlobReference(_FileName);
                    blockBlob.UploadFromStream(image.InputStream);
                }

                // Lưu dữ liệu
                db.products.Add(products);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(products));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Choose_SearchByUserLocation_Click(sender, e);

            if (!IsPostBack)
            {
            }

            if (!ClientScript.IsStartupScriptRegistered("initialize"))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(),
                                                        "initialize", "initialize();", true);
            }



            if (Request.QueryString["Product_ID_Array"] != null)
            {
                product_id_array = Request.QueryString["Product_ID_Array"].Split(',');

                SelectedProduct_div.InnerHtml = "<table border='10', width=100%, borderColor='#00FF00'><tr><td style=\"padding: 5px 10px 5px 10px; background-color: #666666; font-size:large;\">Order Information:</td></tr></table>";
                int orderNumber = 0;
                // Loop over strings
                for (int i = 0; i < product_id_array.Length; i++)
                {
                    orderNumber++;

                    products = products.Select(Convert.ToInt32(product_id_array[i]));
                    warehouse_product_location = warehouse_product_location.Select_By_Product_ID(Convert.ToInt32(product_id_array[i]));
                    Location = Location.Select(warehouse_product_location.Location_ID);



                    Lat  = Convert.ToDecimal(Location.n_lat);
                    Long = Convert.ToDecimal(Location.n_long);

                    passProduct_ID_hf.Value = Convert.ToString(products.FEMA_Description);



                    SelectedProduct_div.InnerHtml += "<Table border='2' width='100%' align ='center'><tr><td width='10%'>" + "<b><font color='black' size='3'>#" + orderNumber + "</b></font></td ><td width='90%' bgcolor='#333333' ></td></tr>" +
                                                     "<tr><td colspan='2'><b><font color='black'>Name: </b>" + products.product_name + "</td></tr>" +
                                                     "<tr><td colspan='2'><b><font color='black'>Type: </b>" + products.product_type + "</font></td></tr>" +
                                                     "<tr><td colspan='2'><b><font color='black'>Discription: </b>" + products.product_desc + "</font></td></tr>" +
                                                     "<tr><td colspan='2'><b><font color='black'>Lat/Long: </b>" + Lat + "/" + Long + "</font></td></tr>" +
                                                     "</td></tr></Table>";

                    EName.Add(products.product_name);
                    EType.Add(products.product_type);
                    EDescription.Add(products.product_desc);

                    //Page.ClientScript.RegisterStartupScript(this.GetType(),
                    //"showMap", "showMap("+ Lat +", " + Long + ");", true);
                }
            }
            else
            {
                //Response.Write("<script>alert('Your order does not exist; This instance has been loged and well be looked into.');</script>");
            }
        }
예제 #21
0
        public override void New()
        {
            Product = new products()
            {
                code   = GetNewProductCode(),
                status = true,
            }; base.New();

            var data = dgv.DataSource as BindingList <products_units>;
            var db   = new SalesDataContext();

            if (db.units.Count() == 0)
            {
                db.units.InsertOnSubmit(new units()
                {
                    name = "قطعة"
                });
                db.SubmitChanges();
                RefreshData();
            }


            Text = $"إضافة صنف جديد";

            data.Add(new products_units()
            {
                factor = 1, unitid = db.units.First().id, barcode = Master.GetNextNumberInString("00000000")
            });
        }
예제 #22
0
        public JsonResult updateProduct(products product)
        {
            string res = "false";

            try
            {
                if (product != null && product.productId != 0)
                {
                    products DBProduct = ProductsBiz.CreateNew().getProductById(product.productId);
                    if (product.status != null)
                    {
                        DBProduct.status = product.status;
                    }
                    var DBres = ProductsBiz.CreateNew().updateProductById(DBProduct);
                    if (DBres)
                    {
                        res = "success";
                        CacheHelper.RemoveAllCache();
                    }
                }
            }
            catch (Exception e)
            {
                _Apilog.WriteLog("更新产品信息异常: " + e.Message);
            }
            return(Json(res));
        }
예제 #23
0
 public void InsertProduct(products productToInsert)
 {
     _conn.Execute("INSERT INTO products (SHORT_DESCRIPTION, CLASS, ITEM, CASE_QTY, LESS_THAN_CASE_PRICE, ONE_CASE, FIVE_CASE, TEN_CASE, GENDER, MATERIAL, WEIGHT, COLOR, SIZE, LENGTH, WIDTH, HEIGHT, KEYWORD, IMAGE, LONG_DESCRIPTION, PRICE_BREAK_4, PRICE_BREAK_5, PAGE, DESCRIPTION_1, DESCRIPTION_2 )" +
                   " VALUES (@short_description, @CLASS, @item, @case_qty, @ltc_price, @one_case, @five_case, @ten_case, @gender, @material, @weight, @color, @size, @length, @width, @height, @keyword,  @image, @long_description, @price_break_4, @price_break_5, @page, @description_1, @description_2 );",
                   new { short_description = productToInsert.SHORT_DESCRIPTION,
                         CLASS             = productToInsert.CLASS,
                         item             = productToInsert.ITEM,
                         description_2    = productToInsert.DESCRIPTION_2,
                         case_qty         = productToInsert.CASE_QTY,
                         ltc_price        = productToInsert.LESS_THAN_CASE_PRICE,
                         one_case         = productToInsert.ONE_CASE,
                         five_case        = productToInsert.FIVE_CASE,
                         ten_case         = productToInsert.TEN_CASE,
                         weight           = productToInsert.WEIGHT, image = productToInsert.IMAGE,
                         color            = productToInsert.COLOR,
                         size             = productToInsert.SIZE,
                         material         = productToInsert.MATERIAL,
                         gender           = productToInsert.GENDER,
                         keyword          = productToInsert.KEYWORD,
                         long_description = productToInsert.LONG_DESCRIPTION,
                         description_1    = productToInsert.DESCRIPTION_1,
                         length           = productToInsert.LENGTH,
                         width            = productToInsert.WIDTH,
                         height           = productToInsert.HEIGHT,
                         price_break_4    = productToInsert.PRICE_BREAK_4,
                         price_break_5    = productToInsert.PRICE_BREAK_5,
                         page             = productToInsert.PAGE });
 }
        public async Task <IActionResult> Edit(int id, [Bind("ProductID,ProductName,ProductDescription")] products products)
        {
            if (id != products.ProductID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(products);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!productsExists(products.ProductID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(products));
        }
예제 #25
0
        public void ProcessRequest(HttpContext context)
        {
            //  GetlistByprocedure()
            List <ConvSerialization> lstjsondata   = new List <ConvSerialization>();
            List <products>          listcustomers = new List <products>();
            BusssinessLogic          Objbal        = new BusssinessLogic();
            string term = context.Request["term"] ?? "";

            context.Response.ContentType = "text/plain";
            string strJson = new StreamReader(context.Request.InputStream).ReadToEnd();
            JavaScriptSerializer jsserialized = new JavaScriptSerializer();
            var result = JsonConvert.DeserializeObject <ConvSerialization>(strJson);

            try
            {
                products objproduct = new products();
                objproduct.ID = result.term;
                listcustomers = Objbal.getProductsListByid(objproduct);
            }
            catch (Exception ex)
            {
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            js.Serialize(listcustomers);
            context.Response.Write(js.Serialize(listcustomers));
        }
        public products ProductDetail(int id)
        {
            conn = new DBMySqlConn();
            MySqlCommand cmd = conn.GetSqlCommand();

            cmd.CommandText = @"Select * from products p " +
                              "inner join categories c on p.CategoryID = c.CategoryID " +
                              "where ProductID = @proId";
            cmd.Parameters.AddWithValue("@proId", id);

            MySqlDataReader dr = cmd.ExecuteReader();

            products pro = new products();

            while (dr.Read())
            {
                pro.ProductID    = Convert.ToInt32(dr["ProductID"]);
                pro.ProductName  = dr["ProductName"].ToString();
                pro.CategoryID   = Convert.ToInt32(dr["CategoryID"]);
                pro.CategoryName = dr["CategoryName"].ToString();
                pro.UnitInStock  = Convert.ToInt32(dr["UnitInStock"]);
                pro.Price        = Convert.ToDouble(dr["Price"]);
            }

            conn.CloseConnection();
            dr.Dispose();

            return(pro);
        }
        public List <products> ProductsList()
        {
            conn = new DBMySqlConn();
            List <products> plist = new List <products>();
            MySqlCommand    cmd   = conn.GetSqlCommand();

            cmd.CommandText = "Select * from products p " +
                              "inner join categories c on p.CategoryID = c.CategoryID ";

            MySqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                products pk = new products();

                pk.ProductID    = Convert.ToInt32(dr["ProductID"]);
                pk.ProductName  = dr["ProductName"].ToString();
                pk.CategoryID   = Convert.ToInt32(dr["CategoryID"]);
                pk.UnitInStock  = Convert.ToInt32(dr["UnitInStock"]);
                pk.CategoryName = dr["CategoryName"].ToString();
                pk.Price        = Convert.ToDouble(dr["Price"]);

                plist.Add(pk);
            }

            conn.CloseConnection();
            dr.Dispose();

            return(plist);
        }
예제 #28
0
        public ActionResult Edit([Bind(Include = "id,product_code,product_name,description,standard_cost,list_price,target_level,reorder_level,minimum_reorder_quantity,quantity_per_unit,discontinued,category")] products products, string image_oldFile, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                string uploadFolderPath = Server.MapPath("~/UploadedFiles/ProductImages");

                if (image == null) // Nếu không cập nhật file (không chọn file)
                {
                    // Giữ nguyên giá trị của tên file trong cột `image`
                    products.image = image_oldFile;
                }
                else // Người ta có chọn file ảnh mới
                {
                    // 1. Xóa file ảnh cũ (để tránh rác)
                    // ~/UploadedFiles/ProductImages/ASP.NET_CodeXuLyDangKy.png -> đường dẫn file ảnh cũ
                    string filePathAnhCu = Path.Combine(uploadFolderPath, (products.image == null ? "" : products.image));
                    if (System.IO.File.Exists(filePathAnhCu))
                    {
                        System.IO.File.Delete(filePathAnhCu);
                    }

                    // 2. Upload file ảnh mới
                    // Xử lý file: lưu file vào thư mục UploadedFiles/ProductImages
                    string _FileName = "";
                    // Di chuyển file vào thư mục mong muốn
                    if (image.ContentLength > 0)
                    {
                        _FileName = Path.GetFileName(image.FileName);                   // QRCode_NenTangUrl.png
                        string _FileNameExtension = Path.GetExtension(image.FileName);  // .png
                        if ((_FileNameExtension == ".png" ||
                             _FileNameExtension == ".jpg" ||
                             _FileNameExtension == ".jpeg"
                             ) == false)
                        {
                            return(View(String.Format("File có đuôi {0} không được chấp nhận. Vui lòng kiểm tra lại!", _FileNameExtension)));
                        }

                        if (Directory.Exists(uploadFolderPath) == false) // Nếu thư mục cần lưu trữ file upload không tồn tại (chưa có) => Tạo mới
                        {
                            Directory.CreateDirectory(uploadFolderPath);
                        }

                        string _path = Path.Combine(uploadFolderPath, _FileName);
                        image.SaveAs(_path);
                    }
                    // Lưu tên file vào database
                    products.image = _FileName;
                }

                /* UPDATE products
                 * SET product_code = 'P3333',
                 *      product_name = 'DELL 333'
                 * WHERE id = 603
                 */
                db.Entry(products).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(products));
        }
예제 #29
0
        public ProductDetailsDTO GetProductDetails(int productId)
        {
            products            selectedProduct = db.products.Include("categories").Include("vendors").Include("vendors.regions").Include("vendors.regions.countries").Include("appellation").FirstOrDefault(x => x.id == productId);
            List <user_rates>   userRates       = db.user_rates.Where(x => x.product_id_id == productId).ToList();
            List <expert_rates> expertRates     = db.expert_rates.Where(x => x.product_id_id == productId).ToList();
            List <expert_product_characteristic> prodCharacteristics = db.expert_product_characteristic.Where(x => x.product_id_id == productId).ToList();

            var sweetnessCharacteristics = prodCharacteristics.Where(x => x.c_header_id_id == 1);
            var acidityCharacteristics   = prodCharacteristics.Where(x => x.c_header_id_id == 2);
            var tanninCharacteristics    = prodCharacteristics.Where(x => x.c_header_id_id == 3);
            var alcoholCharacteristics   = prodCharacteristics.Where(x => x.c_header_id_id == 4);
            var bodyCharacteristics      = prodCharacteristics.Where(x => x.c_header_id_id == 5);

            ProductDetailsDTO newDTO = new ProductDetailsDTO();

            newDTO.ProdID        = selectedProduct.id;
            newDTO.ProdName      = selectedProduct.name;
            newDTO.VendorName    = selectedProduct.vendors.name;
            newDTO.CategoryName  = selectedProduct.categories.name;
            newDTO.RegionName    = selectedProduct.vendors.regions.name;
            newDTO.CountryName   = selectedProduct.vendors.regions.countries.name;
            newDTO.PhotoPath     = selectedProduct.photo_path;
            newDTO.UserAvgRate   = userRates.Count > 0 ? userRates.Sum(x => x.rate) / userRates.Count : 0;
            newDTO.ExpertAvgRate = expertRates.Count > 0 ? expertRates.Sum(x => x.rate) / expertRates.Count : 0;
            newDTO.SweetnessRate = sweetnessCharacteristics.Count() > 0 ? sweetnessCharacteristics.Sum(x => x.characteristic_values) / sweetnessCharacteristics.Count() : 0;
            newDTO.AcidityRate   = acidityCharacteristics.Count() > 0 ? acidityCharacteristics.Sum(x => x.characteristic_values) / acidityCharacteristics.Count() : 0;
            newDTO.TanninRate    = tanninCharacteristics.Count() > 0 ? tanninCharacteristics.Sum(x => x.characteristic_values) / tanninCharacteristics.Count() : 0;
            newDTO.AlcoholRate   = alcoholCharacteristics.Count() > 0 ? alcoholCharacteristics.Sum(x => x.characteristic_values) / alcoholCharacteristics.Count() : 0;
            newDTO.BodyRate      = bodyCharacteristics.Count() > 0 ? bodyCharacteristics.Sum(x => x.characteristic_values) / bodyCharacteristics.Count() : 0;
            newDTO.Apellation    = selectedProduct.appellation != null ? selectedProduct.appellation.name : string.Empty;

            return(newDTO);
        }
예제 #30
0
    public static void Main(string[] args)
    {
        var productList =
            new List <Product> {
            new Product {
                Id    = 1,
                Name  = "John",
                Email = "*****@*****.**",
                phone = 789018,
                age   = 39
            },
            new Product {
                Id = 2, Name = "Chang", Email = "*****@*****.**", phone = 7684919, age = 17
            },
            new Product {
                Id = 3, Name = "Anis", Email = "*****@*****.**", phone = 1078960, age = 13
            },
            new Product {
                Id = 4, Name = "Chef ", Email = "*****@*****.**", phone = 34567322, age = 53
            },
            new Product {
                Id = 4, Name = "neha ", Email = "*****@*****.**", phone = 3456722, age = 21
            },
            new Product {
                Id = 4, Name = "medha", Email = "*****@*****.**", phone = 34567422, age = 53
            },
            new Product {
                Id = 4, Name = "hiamni ", Email = "*****@*****.**", phone = 6, age = 32
            },
            new Product {
                Id = 4, Name = "pooja ", Email = "*****@*****.**", phone = 3456722, age = 17
            },
            new Product {
                Id = 4, Name = "akriti", Email = "*****@*****.**", phone = 3456722, age = 32
            },
            new Product {
                Id = 4, Name = "astha ", Email = "*****@*****.**", phone = 3456722, age = 45
            }
        };


        var javaScriptSerializer = new
                                   System.Web.Script.Serialization.JavaScriptSerializer();
        string jsonString = javaScriptSerializer.Serialize(proList);

        Console.WriteLine(jsonString);

        Console.ReadLine();


        // Load object with some sample data
        products company = new products();

        // Pass "company" object for conversion object to JSON string
        string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(proList);

        // Write that JSON to txt file
        File.WriteAllText(Environment.CurrentDirectory + @"\JSON.json", json);
    }
 public products Delete_products_select(int ID)
 {
     products = products.Select(ID);
     Delete_product_id_txt_lbl.Text = Convert.ToString(products.product_id);
     Delete_Resource_ID_txt_lbl.Text = Convert.ToString(products.Resource_ID);
     Delete_product_name_txt_lbl.Text = Convert.ToString(products.product_name);
     Delete_product_type_txt_lbl.Text = Convert.ToString(products.product_type);
     Delete_product_qty_txt_lbl.Text = Convert.ToString(products.product_qty);
     Delete_product_desc_txt_lbl.Text = Convert.ToString(products.product_desc);
     Delete_product_color_txt_lbl.Text = Convert.ToString(products.product_color);
     Delete_product_size_txt_lbl.Text = Convert.ToString(products.product_size);
     Delete_product_cost_txt_lbl.Text = Convert.ToString(products.product_cost);
     Delete_Product_exp_date_txt_lbl.Text = Convert.ToString(products.Product_exp_date);
     Delete_Product_Alergy_info_txt_lbl.Text = Convert.ToString(products.Product_Alergy_info);
     Delete_Product_refrigde_txt_lbl.Text = Convert.ToString(products.Product_refrigde);
     Delete_Product_Flammable_txt_lbl.Text = Convert.ToString(products.Product_Flammable);
     Delete_Product_Hazard_txt_lbl.Text = Convert.ToString(products.Product_Hazard);
     Delete_Product_Other_txt_lbl.Text = Convert.ToString(products.Product_Other);
     Delete_Product_Min_Inv_txt_lbl.Text = Convert.ToString(products.Product_Min_Inv);
     Delete_Product_Barcode_txt_lbl.Text = Convert.ToString(products.Product_Barcode);
     Delete_Product_subtype_txt_lbl.Text = Convert.ToString(products.Product_subtype);
     Delete_Make_txt_lbl.Text = Convert.ToString(products.Make);
     Delete_Model_txt_lbl.Text = Convert.ToString(products.Model);
     Delete_FEMA_Description_txt_lbl.Text = Convert.ToString(products.FEMA_Description);
     Delete_Year_txt_lbl.Text = Convert.ToString(products.Year);
     Delete_RFID_txt_lbl.Text = Convert.ToString(products.RFID);
     Delete_GPS_txt_lbl.Text = Convert.ToString(products.GPS);
     Delete_Serial_Number_txt_lbl.Text = Convert.ToString(products.Serial_Number);
     Delete_Height_txt_lbl.Text = Convert.ToString(products.Height);
     Delete_Length_txt_lbl.Text = Convert.ToString(products.Length);
     Delete_Depth_txt_lbl.Text = Convert.ToString(products.Depth);
     Delete_Weight_txt_lbl.Text = Convert.ToString(products.Weight);
     Delete_OAI_txt_lbl.Text = Convert.ToString(products.OAI);
     Delete_OAI_Type_txt_lbl.Text = Convert.ToString(products.OAI_Type);
     Delete_Use_txt_lbl.Text = Convert.ToString(products.Use);
     Delete_Brand_txt_lbl.Text = Convert.ToString(products.Brand);
     Delete_Power_Supply_txt_lbl.Text = Convert.ToString(products.Power_Supply);
     Delete_Gas_Type_txt_lbl.Text = Convert.ToString(products.Gas_Type);
     Delete_Needs_Gas_txt_lbl.Text = Convert.ToString(products.Needs_Gas);
     Delete_Needs_Electricity_txt_lbl.Text = Convert.ToString(products.Needs_Electricity);
     Delete_Availability_txt_lbl.Text = Convert.ToString(products.Availability);
     Delete_Datetime_txt_lbl.Text = Convert.ToString(products.Datetime);
     Delete_OpenStatus_txt_lbl.Text = Convert.ToString(products.OpenStatus);
     return products;
 }
 protected void Insert_Select_Record(object sender, EventArgs e)
 {
     products = Insert_products_select(Convert.ToInt32(Insert_products_GridView.SelectedValue));
 }
 protected void Add_To_Order()
 {
     var Product_id = GlobalVariables.JStoC_Product_ID;
     products = products.Select(Convert.ToInt32(Product_id));
     Response.Write("<script>alert('here is the results jimmy - " + products.product_name + " - " + products.product_id + " ' );</script>");
 }
 protected void INSERT(object sender, EventArgs e)
 {
     products = products_insert();
 }
예제 #35
0
파일: Author.cs 프로젝트: PavelPZ/REW
    //d:\LMCom\rew\SolutionToolbar\Forms\DeployForm.cs, DeployBtn_Click
    static CmdDeployProjectResult DeployProject(CmdDeployProject par) {
      var db = NewData.Lib.CreateContext(); var res = new CmdDeployProjectResult();
      string productRoot, zipFn;
      switch (par.action) {
        case DeployProjectAction.deployStart:
          //adjust company v DB
          NewData.Company comp;
          if (!par.isCompany) {
            var user = db.Users.First(u => u.Id == par.id);
            comp = user.MyPublisher != null ? user.MyPublisher : NewData.AdminServ.createCompany(db, string.Format("{0} {1} ({2})", user.FirstName, user.LastName, user.EMail), user, true);
          } else {
            comp = db.Companies.First(c => c.Id == par.id);
          }
          NewData.Lib.SaveChanges(db);
          res.companyId = comp.Id;
          //priprav productRoot
          productRoot = urlFromDesignUrl(comp.Id, par.url);
          zipFn = Path.ChangeExtension(ex.fileNameFromUrl(productRoot + "deploy"), ".zip");
          LowUtils.AdjustFileDir(zipFn);
          break;
        case DeployProjectAction.deployEnd:
        case DeployProjectAction.remove:
          string regProductsFn, prodUrl; List<string> regs;
          //remove
          if (par.action == DeployProjectAction.remove) {
            if (!par.isCompany) {
              var user = db.Users.First(u => u.Id == par.id);
              comp = user.MyPublisher;
            } else {
              comp = db.Companies.First(c => c.Id == par.id);
            }
            if (comp == null) return res;
            par.id = comp.Id;
          }

          //common
          productRoot = urlFromDesignUrl(par.id, par.url); // /publ/0/5/folder_1/course_1/
          zipFn = Path.ChangeExtension(ex.fileNameFromUrl(productRoot + "deploy"), ".zip"); //d:\lmcom\rew\web4\publ\0\5\folder_1\course_1\deploy.zip
          prodUrl = urlFromDesignUrl(par.id, Author.Server.prodUrlFromCourseUrl(par.url)).ToLower(); // /publ/0/5/folder_1/course_1/_prod
          regProductsFn = Path.ChangeExtension(ex.fileNameFromUrl(urlFromDesignUrl(par.id, null)), ".txt"); //d:\lmcom\rew\web4\publ\0\5\meta.txt
          regs = File.Exists(regProductsFn) ? File.ReadAllLines(regProductsFn).ToList() : new List<string>();
          //delete JS a gzip from dirs
          if (regs.IndexOf(prodUrl) >= 0) { regs.Remove(prodUrl); File.WriteAllLines(regProductsFn, regs); }
          foreach (var js in Directory.GetFiles(Path.GetDirectoryName(zipFn), "*.*", SearchOption.AllDirectories)) if (delExts.Contains(Path.GetExtension(js))) File.Delete(js);

          //deployEnd
          if (par.action == DeployProjectAction.deployEnd) {
            //unzip
            using (var str = File.OpenRead(zipFn))
            using (ZipArchive zip = new ZipArchive(str, ZipArchiveMode.Read)) {
              var publisherPath = urlFromDesignUrl(par.id, null).Replace('/', '\\'); // \publ\0\5\
              foreach (var f in zip.Entries.OfType<ZipArchiveEntry>())
                using (var fStr = f.Open()) {
                  var fn = f.FullName.Substring(f.FullName.IndexOf('\\') + 1);
                  fn = Machines.rootDir + publisherPath + fn;
                  var path = Path.GetDirectoryName(fn);
                  if (!Directory.Exists(path)) Directory.CreateDirectory(path);
                  using (var outStr = File.Create(fn)) fStr.CopyTo(outStr);
                }
            }
            File.Delete(zipFn);
            //zaregistruj produkt
            if (regs.IndexOf(prodUrl) == -1) { regs.Add(prodUrl); File.WriteAllLines(regProductsFn, regs); }
            //ticket
            var ticketFn = Machines.rootPath + @"App_Data\tickets\" + par.ticket.name;
            LowUtils.AdjustFileDir(ticketFn);
            XmlUtils.ObjectToFile(Machines.rootPath + @"App_Data\tickets\" + par.ticket.name, par.ticket);
          }

          //common - refresh publisher siteroot.js
          var sitemapUrl = urlFromDesignUrl(par.id, null); // /publ/0/5/
          var files = regs.Select(r => ex.fileNameFromUrl(r));
          var prods = new products { url = sitemapUrl, Items = files.Where(fn => File.Exists(fn)).Select(fn => data.readObject<product>(fn)).ToArray() };
          File.WriteAllText(Path.ChangeExtension(ex.fileNameFromUrl(sitemapUrl + "siteroot"), ".js"), CourseMeta.Lib.serializeObjectToJS(prods), Encoding.UTF8);
          break;
      }
      return res;
    }
 protected void Update_Select_Record(object sender, EventArgs e)
 {
     products = Update_products_select(Convert.ToInt32(Update_products_GridView.SelectedValue));
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            Choose_SearchByUserLocation_Click(sender, e);

            if (!IsPostBack)
            {

            }

            if (!ClientScript.IsStartupScriptRegistered("initialize"))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(),
                    "initialize", "initialize();", true);

            }

            if (Request.QueryString["Product_ID_Array"] != null)
            {

                product_id_array = Request.QueryString["Product_ID_Array"].Split(',');

                SelectedProduct_div.InnerHtml = "<table border='10', width=100%, borderColor='#00FF00'><tr><td style=\"padding: 5px 10px 5px 10px; background-color: #666666; font-size:large;\">Order Information:</td></tr></table>";
                int orderNumber = 0;
                // Loop over strings
                for (int i = 0; i < product_id_array.Length; i++)
                {

                    orderNumber++;

                    products = products.Select(Convert.ToInt32(product_id_array[i]));
                    warehouse_product_location = warehouse_product_location.Select_By_Product_ID(Convert.ToInt32(product_id_array[i]));
                    Location = Location.Select(warehouse_product_location.Location_ID);

                    Lat = Convert.ToDecimal(Location.n_lat);
                    Long = Convert.ToDecimal(Location.n_long);

                    passProduct_ID_hf.Value = Convert.ToString(products.FEMA_Description);

                    SelectedProduct_div.InnerHtml += "<Table border='2' width='100%' align ='center'><tr><td width='10%'>" + "<b><font color='black' size='3'>#" + orderNumber + "</b></font></td ><td width='90%' bgcolor='#333333' ></td></tr>" +
                    "<tr><td colspan='2'><b><font color='black'>Name: </b>" + products.product_name + "</td></tr>" +
                    "<tr><td colspan='2'><b><font color='black'>Type: </b>" + products.product_type + "</font></td></tr>" +
                    "<tr><td colspan='2'><b><font color='black'>Discription: </b>" + products.product_desc + "</font></td></tr>" +
                    "<tr><td colspan='2'><b><font color='black'>Lat/Long: </b>" + Lat + "/" + Long + "</font></td></tr>" +
                    "</td></tr></Table>";

                    EName.Add(products.product_name);
                    EType.Add(products.product_type);
                    EDescription.Add(products.product_desc);

                    //Page.ClientScript.RegisterStartupScript(this.GetType(),
                    //"showMap", "showMap("+ Lat +", " + Long + ");", true);
                }

            }
            else
            {
                //Response.Write("<script>alert('Your order does not exist; This instance has been loged and well be looked into.');</script>");
            }
        }
 protected void UPDATE(object sender, EventArgs e)
 {
     products = products_update(Convert.ToInt32(Update_products_GridView.SelectedValue));
 }
 public products products_update(int ID)
 {
     products = products.Select(ID);
     products.product_id = Convert.ToInt32(Update_product_id_txt.Text);
     products.Resource_ID = Convert.ToInt32(Update_Resource_ID_txt.Text);
     products.product_name = Update_product_name_txt.Text;
     products.product_type = Update_product_type_txt.Text;
     products.product_qty = Convert.ToInt32(Update_product_qty_txt.Text);
     products.product_desc = Update_product_desc_txt.Text;
     products.product_color = Update_product_color_txt.Text;
     products.product_size = Update_product_size_txt.Text;
     products.product_cost = Convert.ToDecimal(Update_product_cost_txt.Text);
     products.Product_exp_date = Convert.ToDateTime(Update_Product_exp_date_txt.Text);
     products.Product_Alergy_info = Update_Product_Alergy_info_txt.Text;
     products.Product_refrigde = Update_Product_refrigde_txt.Text;
     products.Product_Flammable = Update_Product_Flammable_txt.Text;
     products.Product_Hazard = Update_Product_Hazard_txt.Text;
     products.Product_Other = Update_Product_Other_txt.Text;
     products.Product_Min_Inv = Convert.ToInt32(Update_Product_Min_Inv_txt.Text);
     products.Product_Barcode = Update_Product_Barcode_txt.Text;
     products.Product_subtype = Update_Product_subtype_txt.Text;
     products.Make = Update_Make_txt.Text;
     products.Model = Update_Model_txt.Text;
     products.FEMA_Description = Update_FEMA_Description_txt.Text;
     products.Year = Update_Year_txt.Text;
     products.RFID = Update_RFID_txt.Text;
     products.Serial_Number = Update_Serial_Number_txt.Text;
     products.Height = Update_Height_txt.Text;
     products.Length = Update_Length_txt.Text;
     products.Depth = Update_Depth_txt.Text;
     products.Weight = Update_Weight_txt.Text;
     products.OAI = Update_OAI_txt.Text;
     products.OAI_Type = Update_OAI_Type_txt.Text;
     products.Use = Update_Use_txt.Text;
     products.Brand = Update_Brand_txt.Text;
     products.Power_Supply = Update_Power_Supply_txt.Text;
     products.Gas_Type = Update_Gas_Type_txt.Text;
     products.Needs_Gas = Convert.ToBoolean(Update_Needs_Gas_txt.Text);
     products.Needs_Electricity = Convert.ToBoolean(Update_Needs_Electricity_txt.Text);
     products.Availability = Update_Availability_txt.Text;
     products.Datetime = Convert.ToDateTime(Update_Datetime_txt.Text);
     products.OpenStatus = Update_OpenStatus_txt.Text;
     products.Update(products);
     Insert_products_GridView.DataBind();
     Update_products_GridView.DataBind();
     Delete_products_GridView.DataBind();
     return products;
 }
예제 #40
0
        public void Save(bool inTemp = false)
        {
            if (!inTemp)
            {
                products product;

                bool _isExist = false;

                if (isExist(product_id))
                {
                    product = DataBase.entity.products.FirstOrDefault(x => x.product_id == product_id);
                    _isExist = true;
                }
                else
                {
                    product = new products();
                }

                product.product_id = this.product_id;
                product.product_name = this.product_name;
                product.product_shordescription = this.product_shordescription;
                product.product_fulldescription = this.product_fulldescription;
                product.product_price = this.product_price;
                product.product_hit = this.product_hit;
                product.product_enabled = this.product_enabled;
                product.product_approved = this.product_approved;
                product.category_id = this.category_id;
                product.provider_id = this.provider_id;

                if (!_isExist)
                    DataBase.entity.products.Add(product);

                DataBase.entity.SaveChanges();

            }
            else
            {
                products_temp product;

                bool _isExist = false;

                if (isExistInTem(product_id))
                {
                    product = DataBase.entity.products_temp.FirstOrDefault(x => x.product_id == product_id);
                    _isExist = true;
                }
                else
                {
                    product = new products_temp();
                }

                if (!_isExist) product.product_id = this.product_id;
                product.product_name = this.product_name;
                product.product_shordescription = this.product_shordescription;
                product.product_fulldescription = this.product_fulldescription;
                product.product_price = this.product_price;
                product.product_hit = this.product_hit;
                product.product_enabled = this.product_enabled;
                product.product_approved = this.product_approved;
                product.category_id = this.category_id;
                product.provider_id = this.provider_id;

                if (!_isExist)
                    DataBase.entity.products_temp.Add(product);

                DataBase.entity.SaveChanges();
            }
        }
        public string get_product_id(string ID)
        {
            products = products.Select(Convert.ToInt32(ID));

            return products.product_name;
        }
        protected void createInvoicePreview()
        {
            //create invoice preview

            final_invoice_div.Style.Add("display", "block");

            FINAL_to_Name_L.Text = selected_Warehouse.warehouse_name;
            FINAL_to_CompanyName_L.Text = selected_Warehouse.warehouse_name;
            FINAL_to_StreetAddress_L.Text = address.str_add;
            FINAL_to_CityStateZip_L.Text = address.city + " " + address.state + " " + address.zip_plus_four;

            FINAL_caseNumber_L.Text = "Case #/Order #: " + case_intake.case_id + " / " + requestor_Order.OrderID;
            FINAL_date_L.Text = Convert.ToString(DateTime.Now);

            for (int i = 0; i < product_id_array.Length; i++)
            {
                products = products.Select(Convert.ToInt32(product_id_array[i]));
                warehouse_product_location = warehouse_product_location.Select_By_Product_ID(products.product_id);
                warehouse = warehouse.Select(warehouse_product_location.warehouse_id);
                checkWarehouseIDs.Add(warehouse.warehouse_id);
                for (int j = 0; j < checkWarehouseIDs.Count; j++)
                {
                    if (warehouse.warehouse_id != checkWarehouseIDs[j] || checkWarehouseIDs.Count == 1)
                    {
                        selectedWarehouseIDs.Add(warehouse.warehouse_id);
                    }
                }

                int itemNum = i + 1;
                FINAL_orderNum_div.InnerHtml += itemNum + "<br/>";
                FINAL_ProductID_and_WarehouseID_div.InnerHtml += products.product_id + " / " + warehouse.warehouse_id + "<br/>";
                FINAL_orderQTY_div.InnerHtml += 1 + "<br/>";
                FINAL_orderDESCRIPTION_div.InnerHtml += products.product_name + "<br/>";

            }
            FINAL_from_Name_L.Text = "";
            FINAL_from_CompanyName_L.Text = "";
            FINAL_from_StreetAddress_L.Text = "";
            FINAL_from_CityStateZip_L.Text = "";
            for (int k = 0; k < selectedWarehouseIDs.Count; k++)
            {
                warehouse = warehouse.Select(selectedWarehouseIDs[k]);
                address = address.Select(warehouse.address_id);
                if (selectedWarehouseIDs[k] == selectedWarehouseIDs.Count - 1 && selectedWarehouseIDs.Count > 0)
                {
                    FINAL_from_Name_L.Text += selectedWarehouseIDs[k] + ": " + warehouse.warehouse_name + " | ";
                    FINAL_from_CompanyName_L.Text += selectedWarehouseIDs[k] + ": " + warehouse.warehouse_name + " | ";
                    FINAL_from_StreetAddress_L.Text += selectedWarehouseIDs[k] + ": " + address.str_add + " | ";
                    FINAL_from_CityStateZip_L.Text += selectedWarehouseIDs[k] + ": " + address.city + " " + address.state + " " + address.zip_plus_four + " | ";
                }
                else if (selectedWarehouseIDs[k] != selectedWarehouseIDs.Count - 1 && selectedWarehouseIDs.Count > 0)
                {
                    FINAL_from_Name_L.Text += selectedWarehouseIDs[k] + ": " + warehouse.warehouse_name;
                    FINAL_from_CompanyName_L.Text += selectedWarehouseIDs[k] + ": " + warehouse.warehouse_name;
                    FINAL_from_StreetAddress_L.Text += selectedWarehouseIDs[k] + ": " + address.str_add;
                    FINAL_from_CityStateZip_L.Text += selectedWarehouseIDs[k] + ": " + address.city + " " + address.state + " " + address.zip_plus_four;
                }
                else
                {
                    FINAL_from_Name_L.Text += warehouse.warehouse_name;
                    FINAL_from_CompanyName_L.Text += warehouse.warehouse_name;
                    FINAL_from_StreetAddress_L.Text += address.str_add;
                    FINAL_from_CityStateZip_L.Text += address.city + " " + address.state + " " + address.zip_plus_four;
                }
            }
            placeOrder_div.Style.Add("display", "none");
        }