public static void Init(Products.Product targetBase = null, Action <Products.Product> OnComplete = null)
        {
            CompletedAction = OnComplete;

            if (targetBase != null)
            {
                CurrentBase = (Products.Product)targetBase.Clone();
            }
            else
            {
                CurrentBase = new Products.Product();
            }

            int itemCount = TemplateEditor.CurrentTemplate.ItemDefinitions.Count;

            itemList = new string[itemCount];
            for (int i = 0; i < itemCount; i++)
            {
                if (TemplateEditor.CurrentTemplate.ItemDefinitions[i].Id == CurrentBase.ItemId)
                {
                    selection = i;
                }

                itemList[i] = TemplateEditor.CurrentTemplate.ItemDefinitions[i].Id;
            }

            pricesEditor = new PricesEditor();

            // Create window.
            var window = (ProductEditor)GetWindow(typeof(ProductEditor));

            window.minSize = new Vector2(320, 435);
            window.maxSize = new Vector2(320, 435);
            window.Show();
        }
Beispiel #2
0
        private void btnImportStore_Click(object sender, EventArgs e)
        {
            Products.Product item = new Products.Product();
            var myDataTable       = new DataTable();

            openFileDialog1.ShowDialog(this);
            if (string.IsNullOrEmpty(openFileDialog1.FileName))
            {
                MessageBox.Show("هیچ فایلی انتخاب نشده است.");
                return;
            }
            string dbFile = openFileDialog1.FileName;

            using (var conection = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;" + "data source=" + dbFile + ";"))
                using (DataTable dt = new DataTable())
                {
                    string query = "Select * From `tblstoreitem`";
                    using (OleDbDataAdapter adapter = new OleDbDataAdapter(query, conection))
                    {
                        adapter.Fill(dt);
                    }
                    foreach (DataRow dr in dt.Rows)
                    {
                        item.Name         = dr["Iname"].ToString();
                        item.Code         = dr["code"].ToString();
                        item.Price        = dr["Price"].ToString();
                        item.Unit         = dr["UnitName"].ToString();
                        item.Limiter      = dr["Inclimited"].ToString();
                        item.StoreControl = "0";
                        Products.Items.Add(item);
                    }
                    MessageBox.Show(dt.Rows.Count.ToString());
                }
        }
        public void CalculateTaxVatExempt()
        {
            Product product = new Products.Product(1, "TestProduct", 10, Taxes.VATType.Exempt, true);


            Assert.IsTrue(Taxes.TaxCalculator.CalculateItemVAT(product) == 0);
        }
        public void CalculateTaxNotImportTest()
        {
            Product product = new Products.Product(1, "TestProduct", 10, Taxes.VATType.Basic, false);



            Assert.IsTrue(Taxes.TaxCalculator.CalculateItemImportTax(product) == 0);
        }
        private void DrawProducts()
        {
            if (CurrentTemplate.Products == null || CurrentTemplate.Products.Count == 0)
            {
                return;
            }

            GUILayout.Label("Products", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical();
            productsScrollPos = EditorGUILayout.BeginScrollView(productsScrollPos, GUILayout.Width(300), GUILayout.Height(100));

            // DrawProducts

            /// Storage variable if one of them is gonna be removed.
            Products.Product m_itemToRemove = null;

            foreach (var @base in CurrentTemplate.Products)
            {
                EditorGUILayout.BeginHorizontal();

                GUILayout.Label(@base.Id);
                if (GUILayout.Button("Edit"))
                {
                    ProductEditor.Init(@base, (product) => {
                        // New Item created.
                        int target = CurrentTemplate.Products.FindIndex(x => x.Id.Equals(product.Id));
                        if (target != -1)
                        {
                            CurrentTemplate.Products[target] = product;
                            UpdateTemplate();
                        }
                    });
                }

                if (GUILayout.Button("Delete"))
                {
                    if (EditorUtility.DisplayDialog("Beware!", "Do you want to delete this item? All products using this item will be removed also!!", "Go ahead", "Cancel"))
                    {
                        m_itemToRemove = @base;
                    }
                }

                EditorGUILayout.EndHorizontal();
            }

            if (m_itemToRemove != null)
            {
                // Remove the base.
                CurrentTemplate.Products.Remove(m_itemToRemove);

                // Update the template.
                UpdateTemplate();
            }

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }
        public void LoadProduct(Products.Product product)
        {
            if (this.IsFull)
            {
                throw new InvalidOperationException("Vehicle is full!");
            }

            this.trunk.Add(product);
        }
        private bool ValidProduct(Products.Product product)
        {
            if (product.IsValid())
            {
                return(true);
            }

            NotifyErrorValidations(product.ValidationResult);
            return(false);
        }
        public Product Unload()
        {
            if (this.IsEmpty)
            {
                throw new InvalidOperationException("No products left in vehicle!");
            }

            Products.Product product = this.trunk[this.trunk.Count - 1];
            this.trunk.RemoveAt(this.trunk.Count - 1);
            return(product);
        }
Beispiel #9
0
        // Element Operators
        // This sample uses FirstOrDefault to return the first product whose ProductID is 789
        // as a single Product object, unless there is no match, in which case null is returned.
        public void Linq62()
        {
            List <Products.Product> products = Products.GetProductList();

            #region Make Sure to try yourself before looking at the code

            Products.Product product789 = products.FirstOrDefault(p => p.ProductID == 789);

            Console.WriteLine("Product 789 exists: {0}", product789 != null);

            #endregion
        }
Beispiel #10
0
        public void Linq58A()
        {
            List <Products.Product> products = Products.GetProductList();

            #region Make Sure to try yourself before looking at the code

            Products.Product product12 = products.Where(prod => prod.ProductID == 12).First();

            Console.WriteLine();
            Console.WriteLine("*****************************");
            Console.WriteLine("Linq with Linq");
            ObjectDumper.Write(product12);

            #endregion
        }
Beispiel #11
0
        // Element Operators
        // This sample uses First to return the first matching element
        // as a Product, instead of as a sequence containing a Product.
        public void Linq58()
        {
            List <Products.Product> products = Products.GetProductList();

            #region Make Sure to try yourself before looking at the code

            Products.Product product12 = (
                from prod in products
                where prod.ProductID == 12
                select prod)
                                         .First();

            ObjectDumper.Write(product12);

            #endregion
        }
        public object Convert([CanBeNull] object value, [CanBeNull] Type targetType, [CanBeNull] object parameter, [CanBeNull] CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }

            if (value as string == string.Empty)
            {
                return(string.Empty);
            }

            Products.Product val = value as Products.Product;
            Assert.IsNotNull(val, "The value must be a Product variable");

            return(_Target(val));
        }
        public void Handle(CreateProductCommand message)
        {
            var product = new Products.Product(message.Name, message.Description);

            if (!ValidProduct(product))
            {
                return;
            }

            // Criar demais validações de negócio

            _productRepository.Add(product);

            if (Commit())
            {
                _bus.RaiseEvent(new CreatedProductEvent(product.Id, product.Name, product.Description));
            }
        }
        public static Products.Product ToRepository(this DtoProduct dto)
        {
            if (dto == null)
            {
                return(null);
            }
            var model = new Products.Product()
            {
                Id          = dto.Id,
                Name        = dto.Name,
                NeedRecipe  = dto.NeedRecipe,
                Serving     = dto.Serving,
                Views       = dto.Views,
                Type        = dto.Type,
                Producer_Id = dto.Producer?.Id
            };

            return(model);
        }
Beispiel #15
0
        private bool CheckProduct([CanBeNull] Products.Product product)
        {
            if (product == null)
            {
                return(false);
            }

            if (!product.Name.EqualsIgnoreCase(this.name) && !product.OriginalName.EqualsIgnoreCase(this.name))
            {
                return(false);
            }

            if (product.Version != this.version)
            {
                return(false);
            }

            return(product.Revision == this.revision);
        }
Beispiel #16
0
        public HttpResponseMessage GetAllProductCateGories()
        {
            Logger.WriteLine("Getting All Product Categories...");
            SqlConnection           connect     = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlConnection"].ConnectionString);
            List <Products.Product> allProducts = new List <Products.Product>();

            try
            {
                using (connect)
                {
                    SqlDataAdapter adapter = new SqlDataAdapter("Select Category_Code, Category_Desc from Categories ORDER BY Category_Desc", connect);
                    DataTable      dt      = new DataTable();
                    adapter.Fill(dt);

                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            Products.Product product = new Products.Product();
                            product.CategoryName = row["Category_Desc"].ToString();
                            product.CategoryCode = row["Category_Code"].ToString();
                            allProducts.Add(product);
                        }
                    }
                }

                var message = Request.CreateResponse(HttpStatusCode.OK, allProducts);
                message.Headers.Location = new Uri(Request.RequestUri.ToString());
                Logger.Write("Getting All Product Categories successful.");
                return(message);
            }

            catch (Exception ex)
            {
                Logger.WriteLine("Exception @ GetAllProductCateGories() : " + ex.Message.ToString());
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Beispiel #17
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            try
            {
                decimal a = Convert.ToDecimal(txtPrice.Text);

                if (txtItemCode.Text == "" || txtItemName.Text == "" || txtPrice.Text == "" || cbUnitType.Text == "")
                {
                    MessageBox.Show("لطفا اطلاعات را کامل وارد کنید.");
                    return;
                }


                if (edit)
                {
                    string count = "0";
                    if (chbExist.Checked)
                    {
                        if (!string.IsNullOrEmpty(txtCount.Text))
                        {
                            count = txtCount.Text;
                        }
                        else
                        {
                            MessageBox.Show("لطفا کنترل موجودی را غیرفعال کنید و یا تعداد موجودی را وارد کنید.");
                            return;
                        }
                    }

                    UpdateItem(txtItemCode.Text, txtItemCode.Text, txtItemName.Text, txtPrice.Text, cbUnitType.Text, txtLimit.Text, count);
                    MessageBox.Show("به روز شد.");
                    ResetForm();
                    LoadStore();
                    return;
                }
                else
                {
                    Products.Product newItem = new Products.Product();
                    newItem.Code    = txtItemCode.Text;
                    newItem.Name    = txtItemName.Text;
                    newItem.Unit    = cbUnitType.Text;
                    newItem.Price   = txtPrice.Text;
                    newItem.Limiter = txtLimit.Text;
                    if (chbExist.Checked == true)
                    {
                        newItem.StoreControl = txtCount.Text;
                    }
                    else
                    {
                        newItem.StoreControl = "0";
                    }
                    newItem.Status = "";
                    int addNewResutl = Products.Items.Add(newItem);
                    if (addNewResutl == 0)
                    {
                        LoadStore();
                    }
                    else if (addNewResutl == -1)
                    {
                        MessageBox.Show("ثبت کالای جدید بامشکل مواجه شده است.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else if (addNewResutl == 2)
                    {
                        MessageBox.Show("نام یا کد کالا تکراری است.");
                    }

                    //GS.db.Query("SELECT * FROM `store` WHERE `itemName`='" + txtItemName.Text + "' OR `itemCode`='" + txtItemCode.Text + "'");
                }

                //try
                //{

                //    if (GS.db.ResultCount == 0)
                //    {
                //        //string CommandText = "INSERT INTO `store` (`itemName`,`itemUnit`,`itemPrice`,`itemLimiter`,`itemStoreControler`,`itemCode`,`itemStatus`) " +
                //        //"VALUES ('" + txtItemName.Text + "','" + cbUnitType.Text + "','" + txtPrice.Text + "','" + txtLimit.Text + "','" + txtCount.Text + "','" + txtItemCode.Text + "','')";
                //        //GS.db.Query(CommandText);
                //        //LoadStore();
                //    }
                //    else
                //    {
                //        //MessageBox.Show("این کالا قبلا در بانک اطلاعاتی به ثبت رسیده است.");
                //    }
                //}
                //catch (Exception er)
                //{
                //    MessageBox.Show("مشکلی به وجود آمده است" + " : " + er.Message);
                //    //msc.Close();
                //}
                //finally
                //{
                //    //MessageBox.Show("Finally");
                //    //msc.Close();
                //}
            }
            catch
            {
                MessageBox.Show("لطفا جهت قیمت گذاری کالا فقط از اعداد استفاده کنید.");
                txtPrice.Text = "";
                txtPrice.Focus();
            }
        }
 private bool CheckAnalyticsProduct(Products.Product product)
 {
     return(product.Name.Equals("Sitecore Analytics") &&
            product.Revision == this.revision);
 }
 private bool CheckProduct(Products.Product product)
 {
     return((product.Name.EqualsIgnoreCase(this.name) || product.OriginalName.EqualsIgnoreCase(this.name)) &&
            product.Version == this.version &&
            product.Revision == this.revision);
 }