public async Task <IActionResult> AddQuantity([FromBody] ItemForm itemFrom)
        {
            try
            {
                Item item = new Item()
                {
                    Id       = itemFrom.Id,
                    Quantity = itemFrom.Quantity
                };



                var executionStrategy = _appDbContext.Database.CreateExecutionStrategy();
                await executionStrategy.ExecuteAsync(async() =>
                {
                    using var transaction = await _appDbContext.Database.BeginTransactionAsync();
                    try
                    {
                        Item currentItem = await _appDbContext.Items.Where(x => x.Id == itemFrom.Id).FirstOrDefaultAsync();

                        currentItem.Quantity += itemFrom.Quantity;

                        _appDbContext.Items.Update(currentItem);
                        await _appDbContext.SaveChangesAsync();

                        await _appDbContext.Transactions.AddAsync(new Transaction
                        {
                            ItemId      = currentItem.Id,
                            Quantity    = itemFrom.Quantity,
                            Status      = 1,
                            CreatedTime = DateTime.Now,
                            CreatedUser = "******"
                        });
                        await _appDbContext.SaveChangesAsync();

                        await transaction.CommitAsync();


                        var res = await _appDbContext.Items.Include(x => x.ItemCategory).ToListAsync();
                        return(Ok(res));
                    }
                    catch (Exception)
                    {
                        await transaction.RollbackAsync();
                        throw;
                    }
                });
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }


            var res = await _appDbContext.Transactions.Include(x => x.Item).ToListAsync();

            return(Ok(res));
        }
예제 #2
0
 public virtual void ChangeAction(ListViewItem item)
 {
     ItemForm.TextBox.Clear();
     ItemForm.TextBox.Text = item.Text;
     if (ItemForm.ShowDialog() == DialogResult.OK && IsValidItem(ItemForm.TextBox.Text))
     {
         item.Text = ItemForm.TextBox.Text;
     }
 }
예제 #3
0
        private void OnAddClick(object sender, EventArgs e)
        {
            Item obj = new Item();

            if (ItemForm.ShowForm(obj))
            {
                this.LoadListData(obj);
            }
        }
예제 #4
0
        public JsonResult HandleReview(ItemForm form)
        {
            // TODO: Check if the user has any books already reserved
            var success = false;

            try
            {
                var handler = new ConnectionHandler();
                using (MySqlConnection connection = handler.Connection)
                {
                    string       sql = "SELECT reviewId FROM UserReviews WHERE ISBN=@ISBN AND userId=@USERID";
                    MySqlCommand cmd = new MySqlCommand(sql, connection);

                    cmd.Parameters.AddWithValue("@ISBN", form.ISBN);
                    cmd.Parameters.AddWithValue("@USERID", HttpContext.Session.GetString("userId"));
                    int reviewId = -1;

                    using (MySqlDataReader rdr = cmd.ExecuteReader()) {
                        if (rdr.Read())
                        {
                            reviewId = (int)rdr[0];
                        }
                    }

                    // if there is already a review of this book from the user, update it
                    if (reviewId != -1)
                    {
                        cmd.CommandText = "UPDATE UserReviews SET reviewText=@REVIEWTEXT WHERE reviewId=@REVIEWID";
                        cmd.Parameters.AddWithValue("@REVIEWTEXT", form.Data);
                        cmd.Parameters.AddWithValue("@REVIEWID", reviewId);
                        cmd.ExecuteNonQuery();
                        success = true;
                    }
                    else
                    {
                        cmd.CommandText = "INSERT INTO UserReviews(userId, ISBN, rating, reviewText) VALUES (@USERID, @ISBN, '0', @REVIEWTEXT)";
                        cmd.Parameters.AddWithValue("@REVIEWTEXT", form.Data);
                        cmd.ExecuteNonQuery();
                        success = true;
                    }
                }
            }
            catch (Exception ex)
            {
                success = false;
                Console.WriteLine(ex);
            }

            var reason = "unknown";

            if (success)
            {
                reason = "none";
            }
            return(new JsonResult($"{{\"success\":\"{success}\"," +
                                  $"\"reason\":\"{reason}\"}}", new System.Text.Json.JsonSerializerOptions()));
        }
예제 #5
0
 public virtual void OnChangeAction(GenericListViewItem <T> lvitem)
 {
     ItemForm.TextBox.Clear();
     ItemForm.TextBox.Text = lvitem.Text;
     if (ItemForm.ShowDialog() == DialogResult.OK && IsValidItemText(ItemForm.TextBox.Text))
     {
         lvitem.Text = ItemForm.TextBox.Text;
     }
 }
예제 #6
0
        public virtual void AddAction()
        {
            ItemForm.TextBox.Clear();

            if (ItemForm.ShowDialog() == DialogResult.OK)
            {
                AddAction(ItemForm.TextBox.Text);
            }
        }
예제 #7
0
 private void UIComboDataGridView_ButtonClick(object sender, EventArgs e)
 {
     item.FilterColumnName = FilterColumnName;
     item.ShowFilter       = ShowFilter;
     ItemForm.Size         = ItemSize;
     item.ShowButtons      = true;
     item.SetDPIScale();
     item.Translate();
     ItemForm.Show(this);
 }
예제 #8
0
        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }

            ItemForm?.Dispose();
            base.Dispose(disposing);
        }
예제 #9
0
        private void OnExecute(IConsole console, IItemClient itemClient)
        {
            var form = new ItemForm
            {
                Name = Prompt.GetString("Input the name:"),
                Age  = Prompt.GetInt("Input the age:")
            };
            var response = itemClient.Create(form).Result;

            console.WriteLine(response);
        }
예제 #10
0
        private void itemDataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            DataGridViewRow dr = itemDataGridView.SelectedRows[0];

            this.Hide();
            ItemForm aItemForm = new ItemForm();

            aItemForm.itemNameTextBox.Text = dr.Cells["Name"].Value.ToString();
            aItemForm.itemIdLabel.Text     = dr.Cells["ItemID"].Value.ToString();
            aItemForm.Show();
        }
예제 #11
0
 public void DataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (checkIfGridEnableToShowItemForm(Name) && !checkIfDoubleClicedRowsIsHeader(e.RowIndex))
     {
         int itemId   = getItemIdFromRow(e.RowIndex);
         var itemForm = new ItemForm(itemId);
         if (itemForm != null)
         {
             itemForm.Show();
         }
     }
 }
예제 #12
0
 private void mnuItem_Click(object sender, EventArgs e)
 {
     if (itemForm == null || itemForm.IsDisposed)
     {
         itemForm = new ItemForm();
         itemForm.Show();
         itemForm.MdiParent = this;
     }
     else
     {
         itemForm.Activate();
     }
 }
예제 #13
0
        private void OnOpenClick(object sender, EventArgs e)
        {
            Item obj = this.GetSelected();

            if (obj != null)
            {
                obj.RefershData();
            }

            if (ItemForm.ShowForm(obj))
            {
                this.LoadListData(obj);
            }
        }
예제 #14
0
        public async Task <string> Create(ItemForm form)
        {
            var content = new StringContent(JsonConvert.SerializeObject(form), Encoding.UTF8, "application/json");
            var result  = await Client.PostAsync("/api/items", content);

            if (result.IsSuccessStatusCode)
            {
                var stream = await result.Content.ReadAsStreamAsync();

                var item = Deserialize <Item>(stream);
                return($"Item created, info:{item}");
            }

            return("Error occur, please again later.");
        }
예제 #15
0
        public override void Run()
        {
            ItemForm          form      = new ItemForm(item);
            IItemRepository   itemDao   = new NHibernateItemRepository();
            IUnitRepository   unitDao   = new NHibernateUnitRepository();
            IVendorRepository vendorDao = new NHibernateVendorRepository();

            form.UnitsList   += delegate { form.Units = unitDao.FindActive(); };
            form.VendorsList += delegate { form.Vendors = vendorDao.FindActive(); };
            form.ItemSave    += delegate(object sender, ItemEventArgs e) {
                itemDao.SaveOrUpdate(e.Item);
                form.Close();
            };
            WorkbenchSingleton.AddChild(form, "Edit Item");
        }
        protected void ProcessView()
        {
            EditItemControl = (ItemForm)LoadControl(System.IO.Path.Combine(TemplateSourceDirectory, "SexyContent/EAV/Controls/ItemForm.ascx"));
            EditItemControl.DefaultCultureDimension = DefaultLanguageID != 0 ? DefaultLanguageID : new int?();
            EditItemControl.IsDialog = false;
            EditItemControl.HideNavigationButtons  = true;
            EditItemControl.PreventRedirect        = true;
            EditItemControl.AttributeSetId         = AttributeSetID;
            EditItemControl.AssignmentObjectTypeId = SexyContent.AssignmentObjectTypeIDDefault;
            EditItemControl.ZoneId = ZoneId;
            EditItemControl.AppId  = AppId;
            EditItemControl.AddClientScriptAndCss = false;
            EditItemControl.ItemHistoryUrl        = "";

            var newItemUrl = EditUrl(this.TabID, SexyContent.ControlKeys.EditContentGroup, true, new string[] {});

            EditItemControl.NewItemUrl = newItemUrl + (newItemUrl.Contains("?") ? "&" : "?") + "AppID=" + AppId.ToString() + "&mid=" + ModuleID.ToString() + "&AttributeSetId=[AttributeSetId]&EditMode=New&CultureDimension=" + this.LanguageID;

            // If ContentGroupItem has Entity, edit that; else create new Entity
            if (Item != null && Item.EntityID.HasValue)
            {
                EditItemControl.Updated += EditItem_OnEdited;
                EditItemControl.EntityId = Item.EntityID.Value;
                EditItemControl.InitForm(FormViewMode.Edit);

                hlkHistory.Visible     = true;
                hlkHistory.NavigateUrl = EditUrl("", "", SexyContent.ControlKeys.EavManagement, new string[] { "AppID", AppId.ToString(), "ManagementMode", "ItemHistory", "EntityId", Item.EntityID.Value.ToString(), "mid", ModuleID.ToString() });
            }
            // Create a new Entity
            else
            {
                EditItemControl.Inserted += NewItem_OnInserted;
                EditItemControl.Visible   = false;

                if (ItemType == ContentGroupItemType.Content || ItemType == ContentGroupItemType.ListContent)
                {
                    EditItemControl.Visible = true;
                }
                else
                {
                    pnlReferenced.Visible = true;
                }

                EditItemControl.InitForm(FormViewMode.Insert);
            }

            phNewOrEditItem.Controls.Add(EditItemControl);
        }
예제 #17
0
        private void edit_Click(object sender, EventArgs e)
        {
            PanelStart panel = Panels.getPanelByName(Panels.PanelsName.PSTART) as PanelStart;
            var        row   = panel.getGridViewItemRow();

            if (panel.Visible == true && panel.getGridViewName() == DataGridViewNew.DGVMainDataNames.items.ToString() &&
                row != null)
            {
                var itemId = Int32.Parse(row.Cells[0].Value.ToString());
                var form   = new ItemForm(itemId);
                form.Show();
            }
            else
            {
                MessageBox.Show(Utils.GetEnumDescription(Messages.warnings.EDIT), "Warrning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #18
0
        public IActionResult Create(ItemForm form)
        {
            var items = _cache.Get <List <Item> >(_key) ?? new List <Item>();

            var item = new Item
            {
                Id   = Guid.NewGuid().ToString("N"),
                Name = form.Name,
                Age  = form.Age
            };

            items.Add(item);

            _cache.Set(_key, items);

            return(Ok(item));
        }
예제 #19
0
        private Item OpenItemFormDialog(string formTitle, Item input = null)
        {
            Item output = null;

            using (ItemForm iform = new ItemForm(input))
            {
                iform.Text = formTitle;

                DialogResult result = iform.ShowDialog();

                if (result == DialogResult.OK)
                {
                    output = JsonConvert.DeserializeObject <Item>(iform.Data);
                }
            }

            return(output);
        }
        public async Task <IActionResult> UpdateAsync([FromBody] ItemForm itemForm)
        {
            try
            {
                var modelresources = _mapper.Map <Item>(itemForm);
                _appDbContext.Items.Update(modelresources);
                _appDbContext.SaveChanges();

                var res = await _appDbContext.Items
                          .Select(ItemViewModel.SelectAllItem)
                          .ToListAsync();

                return(Ok(res));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
예제 #21
0
        private void menu_Clicked(object sender, ToolStripItemClickedEventArgs e)
        {
            var clicked = e.ClickedItem.Text;

            if (clicked == "Podgląd")
            {
                var itemId   = getItemIdFromRow(menuClickedRow);
                var itemForm = new ItemForm(itemId);
                if (itemForm != null)
                {
                    itemForm.Show();
                }
            }
            else if (clicked == "Usuń")
            {
                string messageBoxText = String.Format("Czy na pewno chcesz usunąć {0}?",
                                                      Rows[menuClickedRow].Cells["name"].Value.ToString());
                string            caption = "Usuwanie";
                MessageBoxButtons button  = MessageBoxButtons.YesNo;
                DialogResult      res     = MessageBox.Show(messageBoxText, caption, button);
                if (res == DialogResult.Yes)
                {
                    var itemId = getItemIdFromRow(menuClickedRow);
                    queries.changeItemDeletedById(itemId, true);
                    Panels.refreshPanelStartGrid();
                }
            }
            else if (clicked == "Przywróć")
            {
                string messageBoxText = String.Format("Czy na pewno chcesz przywrócić {0}?",
                                                      Rows[menuClickedRow].Cells["name"].Value.ToString());
                string            caption = "Przywracanie";
                MessageBoxButtons button  = MessageBoxButtons.YesNo;
                DialogResult      res     = MessageBox.Show(messageBoxText, caption, button);
                if (res == DialogResult.Yes)
                {
                    var itemId = getItemIdFromRow(menuClickedRow);
                    queries.changeItemDeletedById(itemId, false);
                    Panels.refreshPanelBinGrid();
                }
            }
        }
예제 #22
0
        public JsonResult OnPost([FromBody] ItemForm form)
        {
            JsonResult res = new JsonResult("{\"success\":\"False\"}", new System.Text.Json.JsonSerializerOptions());

            Console.WriteLine("Item Form Post Action: " + form.Action);
            Console.WriteLine($"request: {{action: {form.Action}, data:{form.Data}}}");
            if (!ModelState.IsValid)
            {
                Console.WriteLine("Item Form Post: Invalid model state!");
            }
            else if (form.Action == "reserve")
            {
                res = HandleReserve(form);
            }
            else if (form.Action == "review")
            {
                res = HandleReview(form);
            }

            return(res);
        }
예제 #23
0
        public virtual void OnAddAction(String text)
        {
            while (true)
            {
                if (TryConvertToItem(text, out T item) && IsValidItem(item))
                {
                    TryInsert(SelectedIndices.OfType <Int32>().FirstOr(SelectedIndices.Count), item);
                }
                else
                {
                    ItemForm.TextBox.Clear();
                    ItemForm.TextBox.Text = text;

                    if (ItemForm.ShowDialog() == DialogResult.OK)
                    {
                        text = ItemForm.TextBox.Text;
                        continue;
                    }
                }

                break;
            }
        }
예제 #24
0
        public virtual void AddAction(String text)
        {
            while (true)
            {
                if (IsValidItem(text))
                {
                    Add(text);
                }
                else
                {
                    ItemForm.TextBox.Clear();
                    ItemForm.TextBox.Text = text;

                    if (ItemForm.ShowDialog() == DialogResult.OK)
                    {
                        text = ItemForm.TextBox.Text;
                        continue;
                    }
                }

                break;
            }
        }
예제 #25
0
파일: Form1.cs 프로젝트: igordsr/GeekBurger
        private void control(int action)
        {
            ;
            switch (ondeEstou.GetType().Name)
            {
            case "ProdutoForm":
                ProdutoForm produtoForm = new ProdutoForm(action);
                produtoForm.Execute(Convert.ToInt32(indice));
                produtoForm.Show();
                break;

            case "IngredienteForm":
                IngredienteForm ingredienteForm = new IngredienteForm(action);
                ingredienteForm.Execute(Convert.ToInt32(indice));
                ingredienteForm.Show();
                break;

            case "ItemForm":
                ItemForm itemForm = new ItemForm(action);
                itemForm.Execute(Convert.ToInt32(indice));
                itemForm.Show();
                break;
            }
        }
예제 #26
0
        private void detailButton_Click(object sender, EventArgs e)
        {
            var form = new ItemForm(1, null, new AddressSearcherStub());

            form.Show(this);
        }
예제 #27
0
 private void UIColorPicker_ButtonClick(object sender, EventArgs e)
 {
     item.SelectedColor = Value;
     ItemForm.Show(this);
 }
예제 #28
0
        private void SubForm_Load(object sender, EventArgs e)
        {
            string Pam_id = Name;

            switch (Pam_id)
            {
            case "Role":
                RoleUcForm _RoleForm = new RoleUcForm(this);
                _RoleForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_RoleForm);
                break;

            case "Usr":
                UsrUcForm _UsrForm = new UsrUcForm(this);
                _UsrForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_UsrForm);
                break;

            case "Department":
                DeptForm _deptForm = new DeptForm(this);
                _deptForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_deptForm);
                break;

            case "Employee":
                EmployeeForm _EmployeeForm = new EmployeeForm(this);
                _EmployeeForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_EmployeeForm);
                break;

            case "Csv":
                CsvForm _csvForm = new CsvForm(this);
                _csvForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_csvForm);
                break;

            case "Currency":
                CurrencyForm _currencyForm = new CurrencyForm(this);
                _currencyForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_currencyForm);
                break;

            case "SalesType":
                SalesTypeForm _salesTypeForm = new SalesTypeForm(this);
                _salesTypeForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_salesTypeForm);
                break;

            case "BusinessType":
                BusinessTypeForm _businessTypeForm = new BusinessTypeForm(this);
                _businessTypeForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_businessTypeForm);
                break;

            case "ItemUt":
                ItemUtForm _itemUtForm = new ItemUtForm(this);
                _itemUtForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_itemUtForm);
                break;

            case "ItemKind":
                ItemKindForm _itemKindForm = new ItemKindForm(this);
                _itemKindForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_itemKindForm);
                break;

            case "Warehouse":
                WarehouseForm _warehouseForm = new WarehouseForm(this);
                _warehouseForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_warehouseForm);
                break;

            case "ProductArea":
                ProductAreaForm _productAreaForm = new ProductAreaForm(this);
                _productAreaForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_productAreaForm);
                break;

            case "Item":
                ItemForm _itemForm = new ItemForm(this);
                _itemForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_itemForm);
                break;

            case "RequestCollectionOrder":
                RequestCollectionOrderForm _OrderForm = new RequestCollectionOrderForm(this);
                _OrderForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_OrderForm);
                break;

            case "PlanningOrderInfoInput":
                PlanningOrderInfoInputForm _FrorecastForm = new PlanningOrderInfoInputForm(this);
                _FrorecastForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_FrorecastForm);
                break;

            case "TaskNotifyOrder":
                TaskNotifyOrderForm _TaskNotifyOrderForm = new TaskNotifyOrderForm(this);
                _TaskNotifyOrderForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_TaskNotifyOrderForm);
                break;

            case "ShippingInfoConfirmOrder":
                ShippingInfoConfirmOrderForm _ShippingInfoConfirmOrderForm = new ShippingInfoConfirmOrderForm(this);
                _ShippingInfoConfirmOrderForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_ShippingInfoConfirmOrderForm);
                break;

            case "PgmTransferWarningSetting":
                PgmTransferWarningSettingForm _PgmTransferWarningSettingForm = new PgmTransferWarningSettingForm(this);
                _PgmTransferWarningSettingForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_PgmTransferWarningSettingForm);
                break;

            case "Project":
                ProjectForm _ProjectForm = new ProjectForm(this);
                _ProjectForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_ProjectForm);
                break;

            case "ProjectStage":
                ProjectStageForm _ProjectStageForm = new ProjectStageForm(this);
                _ProjectStageForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_ProjectStageForm);
                break;

            case "ShippingAddress":
                ShippingAddressForm _ShippingAddressForm = new ShippingAddressForm(this);
                _ShippingAddressForm.Dock = DockStyle.Fill;
                this.PalView.Controls.Add(_ShippingAddressForm);
                break;

            default:
                break;
            }
        }
예제 #29
0
        protected void ProcessView()
        {
            var attributeSet = DataSource.GetCache(ZoneId, AppId).GetContentType(AttributeSetStaticName);

            EditItemControl = (ItemForm)LoadControl(Path.Combine(TemplateSourceDirectory, "SexyContent/EAV/Controls/ItemForm.ascx"));
            EditItemControl.DefaultCultureDimension = DefaultLanguageID != 0 ? DefaultLanguageID : new int?();
            EditItemControl.IsDialog = false;
            EditItemControl.HideNavigationButtons = true;
            EditItemControl.PreventRedirect = true;
            EditItemControl.AttributeSetId = attributeSet.AttributeSetId;
            EditItemControl.AssignmentObjectTypeId = SexyContent.AssignmentObjectTypeIDDefault;
            EditItemControl.ZoneId = ZoneId;
            EditItemControl.AppId = AppId;
            EditItemControl.AddClientScriptAndCss = false;
            EditItemControl.ItemHistoryUrl = "";

            var newItemUrl = EditUrl(TabID, SexyContent.ControlKeys.EditContentGroup, true, new string[] {});
            EditItemControl.NewItemUrl = newItemUrl + (newItemUrl.Contains("?") ? "&" : "?") + "AppID=" + AppId + "&mid=" + ModuleID + "&AttributeSetId=[AttributeSetId]&EditMode=New&CultureDimension=" + LanguageID;

            // If ContentGroupItem has Entity, edit that; else create new Entity
            if (!NewMode && Entity != null)
            {
                EditItemControl.Updated += EditItem_OnEdited;
                EditItemControl.EntityId = Entity.EntityId;
                EditItemControl.InitForm(FormViewMode.Edit);

                hlkHistory.Visible = true;
                hlkHistory.NavigateUrl = EditUrl("", "", SexyContent.ControlKeys.EavManagement, new[] { "AppID", AppId.ToString(), "ManagementMode", "ItemHistory", "EntityId", Entity.EntityId.ToString(), "mid", ModuleID.ToString() });
            }
            // Create a new Entity
            else
            {
                EditItemControl.Inserted += NewItem_OnInserted;
                EditItemControl.Visible = false;

                if (ItemType == "Content" || ItemType == "ListContent")
                    EditItemControl.Visible = true;
                else
                    pnlReferenced.Visible = true;

                EditItemControl.InitForm(FormViewMode.Insert);
            }

            phNewOrEditItem.Controls.Add(EditItemControl);
        }
예제 #30
0
        protected void ProcessView()
        {
            EditItemControl = (ItemForm)LoadControl(Path.Combine(TemplateSourceDirectory, "SexyContent/EAV/Controls/ItemForm.ascx"));
            EditItemControl.DefaultCultureDimension = DefaultLanguageID != 0 ? DefaultLanguageID : new int?();
            EditItemControl.IsDialog = false;
            EditItemControl.HideNavigationButtons = true;
            EditItemControl.PreventRedirect = true;
            EditItemControl.AttributeSetId = AttributeSetID;
            EditItemControl.AssignmentObjectTypeId = AssignmentObjectTypeId;
            EditItemControl.KeyNumber = KeyNumber;
            EditItemControl.KeyGuid = KeyGuid;
            EditItemControl.ZoneId = ZoneId;
            EditItemControl.ReturnUrl = "";
            EditItemControl.AppId = AppId;
            EditItemControl.AddClientScriptAndCss = false;
            EditItemControl.ItemHistoryUrl = "";
            EditItemControl.PreventRedirect = Request.QueryString["PreventRedirect"] == "true";

            var newItemUrl = EditUrl(TabID, SexyContent.ControlKeys.EditContentGroup, true, new string[] { });
            EditItemControl.NewItemUrl = newItemUrl + (newItemUrl.Contains("?") ? "&" : "?") + "AppID=" + AppId + "&mid=" + ModuleID + "&AttributeSetId=[AttributeSetId]&EditMode=New&CultureDimension=" + LanguageID;

            // If ContentGroupItem has Entity, edit that; else create new Entity
            if (EntityId.HasValue)
            {
                EditItemControl.Updated += EditItem_OnEdited;
                EditItemControl.EntityId = EntityId.Value;
                EditItemControl.InitForm(FormViewMode.Edit);

                hlkHistory.Visible = true;
                hlkHistory.NavigateUrl = EditUrl("", "", SexyContent.ControlKeys.EavManagement, new[] { "AppID", AppId.ToString(), "ManagementMode", "ItemHistory", "EntityId", EntityId.Value.ToString(), "mid", ModuleID.ToString() });
            }
            // Create a new Entity
            else
            {
                EditItemControl.Inserted += NewItem_OnInserted;
                EditItemControl.Visible = true;
                EditItemControl.InitForm(FormViewMode.Insert);
            }

            phNewOrEditItem.Controls.Add(EditItemControl);
        }
예제 #31
0
        private void itemFormButton_Click(object sender, EventArgs e)
        {
            ItemForm aItemForm = new ItemForm();

            aItemForm.Show();
        }
예제 #32
0
        public IActionResult Catalog(String dresses, String leggings, String bloudseAndshirts,
                                     String coatsAndjackets, String hoodiesAndsweats, String denim, String jeans, String jumpersAndcardigans,
                                     string size, int price, string deletion, string subcat, string subsize, int subprice, int cpId, int wpId,
                                     int cart_remove, int wish_remove, int dpId, string sort)
        {
            if (cart_remove != 0)
            {
                //Product cp = db.Product.Where(p => p.id == cart_remove).FirstOrDefault();
                int ind = cart_products.IndexOf(cart_products.Where(p => p.id == cart_remove).FirstOrDefault());
                cart_products.RemoveAt(ind);
                cart_images.RemoveAt(ind);
                cart_items.RemoveAt(ind);
            }
            if (wish_remove != 0)
            {
                //Product cp = db.Product.Where(p => p.id == wish_remove).FirstOrDefault();
                int ind = wish_products.IndexOf(wish_products.Where(p => p.id == wish_remove).FirstOrDefault());
                wish_products.RemoveAt(ind);
                wish_images.RemoveAt(ind);
            }
            if (cpId != 0)
            {
                //Product cp = db.Product.Where(p => p.id == cpId).FirstOrDefault();
                if (!cart_products.Contains(cart_products.Where(p => p.id == cpId).FirstOrDefault()))
                {
                    cart_products.Add(db.Product.Where(p => p.id == cpId).FirstOrDefault());
                    cart_images.Add(db.Image.Where(p => p.whose == (1000 + cpId)).FirstOrDefault());
                    ItemForm iform = new ItemForm()
                    {
                        product  = cpId,
                        price    = Convert.ToInt32(db.Product.Where(p => p.id == cpId).FirstOrDefault().price),
                        quantity = 1,
                        sizes    = db.ProductSize.Where(p => p.product == cpId).ToList(),
                    };
                    cart_items.Add(iform);
                }
            }
            if (wpId != 0)
            {
                //Product wp = db.Product.Where(p => p.id == wpId).FirstOrDefault();
                if (!wish_products.Contains(wish_products.Where(p => p.id == wpId).FirstOrDefault()))
                {
                    wish_products.Add(db.Product.Where(p => p.id == wpId).FirstOrDefault());
                    wish_images.Add(db.Image.Where(p => p.whose == (1000 + wpId)).FirstOrDefault());
                }
            }
            if (dpId != 0)
            {
                if (!detail_products.Contains(detail_products.Where(d => d.id == dpId).FirstOrDefault()))
                {
                    detail_products.Add(db.Product.Where(d => d.id == dpId).FirstOrDefault());
                    detail_images.Add(db.Image.Where(d => d.whose == (1000 + dpId)).FirstOrDefault());
                }
            }


            if (deletion != null && deletion != "")
            {
                if (deletion == "category")
                {
                    //catalog.category = "";
                    //c_cat = true;
                    category_filters.Remove(subcat.ToLower());
                }
                if (deletion == "size")
                {
                    //catalog.size = "";
                    //c_size = true;
                    size_filters.Remove(subsize);
                }
                if (deletion == "price")
                {
                    //catalog.price = 0;
                    //c_price = true;
                    price_filters.Remove(subprice);
                }
            }
            if (price != 0 && !price_filters.Contains(price))
            {
                price_filters.Add(price);
            }
            if (size != null && size != "" && !size_filters.Contains(size))
            {
                size_filters.Add(size);
            }
            if (dresses != null && dresses != "" && !category_filters.Contains(dresses))
            {
                category_filters.Add(dresses);
            }
            List <Product> priced_products = new List <Product>();

            products     = new List <Product>();
            productSizes = new List <ProductSize>();

            if (price_filters == null || price_filters.Count() == 0)
            {
                priced_products = db.Product.ToList();
            }
            else
            {
                foreach (var p in price_filters)
                {
                    if (p == 1)
                    {
                        List <Product> pds = db.Product.Where(s => (Convert.ToInt32(s.price)) >= 10 && (Convert.ToInt32(s.price)) <= 49).ToList();
                        priced_products.AddRange(pds);
                    }
                    else if (p == 2)
                    {
                        List <Product> pds = db.Product.Where(s => (Convert.ToInt32(s.price)) >= 50 && (Convert.ToInt32(s.price)) <= 99).ToList();
                        priced_products.AddRange(pds);
                    }
                    else if (p == 3)
                    {
                        List <Product> pds = db.Product.Where(s => (Convert.ToInt32(s.price)) >= 100 && (Convert.ToInt32(s.price)) <= 199).ToList();
                        priced_products.AddRange(pds);
                    }
                    else if (p == 4)
                    {
                        List <Product> pds = db.Product.Where(s => (Convert.ToInt32(s.price)) >= 200).ToList();
                        priced_products.AddRange(pds);
                    }

                    //catalog.size = size;
                }
            }


            if (size_filters == null || size_filters.Count() == 0)
            {
                productSizes = db.ProductSize.ToList();
            }
            else
            {
                foreach (string s in size_filters)
                {
                    List <ProductSize> sz = db.ProductSize.Where(_s => _s.size == s).ToList();
                    productSizes.AddRange(sz);
                }
            }
            if (category_filters == null || category_filters.Count() == 0)
            {
                products = priced_products;
            }
            else
            {
                foreach (var c in category_filters)
                {
                    List <Product> _category = priced_products.Where(p => p.category.Contains(c.ToLower())).ToList();
                    products.AddRange(_category);
                }
            }


            //

            /*string cat=catalog.category*/
            ;
            //string sz = catalog.size;
            //int pr = catalog.price;
            //if (dresses != null && dresses != "")
            //{
            //    products = products.Where(p => p.category.Contains(dresses)).ToList();
            //    catalog.category = dresses.ToUpper();
            //    category_filters.Add(dresses);

            //}
            if (leggings != null && leggings != "")
            {
                products = products.Where(p => p.category.Contains(leggings)).ToList();
                //catalog.category = dresses.ToUpper();
                //c_cat = true;

                products     = db.Product.ToList();
                productSizes = db.ProductSize.ToList();
            }
            if (bloudseAndshirts != null && bloudseAndshirts != "")
            {
                products = products.Where(p => p.category.Contains(bloudseAndshirts)).ToList();
                //catalog.category = dresses.ToUpper();
                //c_cat = true;
            }
            if (leggings != null && leggings != "")
            {
                products         = products.Where(p => p.category.Contains(leggings)).ToList();
                catalog.category = dresses.ToUpper();
                c_cat            = true;
            }
            if (coatsAndjackets != null && coatsAndjackets != "")
            {
                products = products.Where(p => p.category.Contains(coatsAndjackets)).ToList();
                //catalog.category = dresses.ToUpper();
                //c_cat = true;
            }
            if (bloudseAndshirts != null && bloudseAndshirts != "")
            {
                products         = products.Where(p => p.category.Contains(bloudseAndshirts)).ToList();
                catalog.category = dresses.ToUpper();
                c_cat            = true;
            }
            if (hoodiesAndsweats != null && hoodiesAndsweats != "")
            {
                products = products.Where(p => p.category.Contains(hoodiesAndsweats)).ToList();
                //catalog.category = dresses.ToUpper();
                //c_cat = true;
            }
            if (coatsAndjackets != null && coatsAndjackets != "")
            {
                products         = products.Where(p => p.category.Contains(coatsAndjackets)).ToList();
                catalog.category = dresses.ToUpper();
                c_cat            = true;
            }
            if (denim != null && denim != "")
            {
                products = products.Where(p => p.category.Contains(denim)).ToList();
                //catalog.category = dresses.ToUpper();
                //c_cat = true;
            }
            if (hoodiesAndsweats != null && hoodiesAndsweats != "")
            {
                products         = products.Where(p => p.category.Contains(hoodiesAndsweats)).ToList();
                catalog.category = dresses.ToUpper();
                c_cat            = true;
            }
            if (denim != null && denim != "")
            {
                products         = products.Where(p => p.category.Contains(denim)).ToList();
                catalog.category = dresses.ToUpper();
                c_cat            = true;
            }
            if (jumpersAndcardigans != null && jumpersAndcardigans != "")
            {
                products         = products.Where(p => p.category.Contains(jumpersAndcardigans)).ToList();
                catalog.category = dresses.ToUpper();
                c_cat            = true;
            }
            if (jeans != null && jeans != "")
            {
                products         = products.Where(p => p.category.Contains(jeans)).ToList();
                catalog.category = dresses.ToUpper();
                c_cat            = true;
            }



            if (price == 1)
            {
                products           = products.Where(p => Convert.ToInt32(p.price) >= 10 && Convert.ToInt32(p.price) <= 49).ToList();
                this.catalog.price = price;
                c_price            = true;
            }
            else if (price == 2)
            {
                products           = products.Where(p => Convert.ToInt32(p.price) >= 50 && Convert.ToInt32(p.price) <= 99).ToList();
                this.catalog.price = price;
                c_price            = true;
            }
            else if (price == 3)
            {
                products           = products.Where(p => Convert.ToInt32(p.price) >= 100 && Convert.ToInt32(p.price) <= 199).ToList();
                this.catalog.price = price;
                c_price            = true;
            }
            else if (price == 4)
            {
                products           = products.Where(p => Convert.ToInt32(p.price) >= 200).ToList();
                this.catalog.price = price;
                c_price            = true;
            }

            if (size == "S" || size == "M" || size == "L" || size == "XL" || size == "2XL" || size == "One Size")
            {
                productSizes      = productSizes.Where(s => s.size == size).ToList();
                this.catalog.size = size;
                c_size            = true;
            }



            initCatalog(products, productSizes, images);
            if (c_price == false)
            {
                this.catalog.price = old_price;
            }
            if (c_size == false)
            {
                this.catalog.size = old_size;
            }
            if (c_cat == false)
            {
                this.catalog.category = old_category;
            }

            if (cart != null && cart != "")
            {
                Product pd = this.catalog.products.Where(p => p.product.id == Convert.ToInt32(cart)).FirstOrDefault().product;

                ////Item cd = new Item()
                ////{
                ////    product = pd.id,
                ////    cart =
                ////};
                //this.catalog.cartProducts.Add(pd);
                //this.catalog.cartTotal +=pd.price;
                Item cp = new Item()
                {
                    products = products.Where(p => p.category.Contains(jumpersAndcardigans)).ToList();
                    //catalog.category = dresses.ToUpper();
                    //c_cat = true;

                    this.catalog.items = db.Item.Where(i => i.cart == 1).ToList();
                    List <int> pIds = new List <int>();

                    foreach (var i in this.catalog.items)
                    {
                        if (!pIds.Contains(i.product))
                        {
                            pIds.Add(i.product);
                        }
                    }
                    this.catalog.cartTotal = 0;
                    foreach (var p in this.catalog.products)
                    {
                        products = products.Where(p => p.category.Contains(jeans)).ToList();
                        //catalog.category = dresses.ToUpper();
                        //c_cat = true;
                    }
                }
            }
            if (cartRemove != null && cartRemove != "")
            {
                Product pd = this.catalog.products.Where(p => p.product.id == Convert.ToInt32(cartRemove)).FirstOrDefault().product;

                ////Item cd = new Item()
                ////{
                ////    product = pd.id,
                ////    cart =
                ////};
                //this.catalog.cartProducts.Add(pd);
                //this.catalog.cartTotal +=pd.price;
                Item cp = db.Item.Where(i => i.product == pd.id).FirstOrDefault();
                db.Item.Remove(cp);
                db.SaveChanges();

                //if (price == 1)
                //{
                //    products = products.Where(p => Convert.ToInt32(p.price) >= 10 && Convert.ToInt32(p.price) <= 49).ToList();
                //    catalog.price = price;
                //    c_price = true;

                //}
                //else if (price == 2)
                //{
                //    products = products.Where(p => Convert.ToInt32(p.price) >= 50 && Convert.ToInt32(p.price) <= 99).ToList();
                //    catalog.price = price;
                //    c_price = true;

                //}
                //else if (price == 3)
                //{
                //    products = products.Where(p => Convert.ToInt32(p.price) >= 100 && Convert.ToInt32(p.price) <= 199).ToList();
                //    catalog.price = price;
                //    c_price = true;

                //}
                //else if (price == 4)
                //{
                //    products = products.Where(p => Convert.ToInt32(p.price) >= 200).ToList();
                //    catalog.price = price;
                //    c_price = true;

                //}

                //if (size == "S" || size == "M" || size == "L" || size == "XL" || size == "2XL" || size == "One Size")
                //{
                //    productSizes = productSizes.Where(s => s.size == size).ToList();
                //    catalog.size = size;
                //    c_size = true;

                //}



                initCatalog(products, productSizes, images);
                catalog.price_filters    = price_filters;
                catalog.size_filters     = size_filters;
                catalog.category_filters = category_filters;
                catalog.cart_product     = cart_products;
                catalog.wish_product     = wish_products;
                catalog.wish_images      = wish_images;
                catalog.cart_images      = cart_images;
                catalog.detail_images    = detail_images;
                catalog.detail_product   = detail_products;
                catalog.items            = cart_items;


                //if (c_price == false)
                //{
                //    catalog.price = old_price;
                //}
                //if (c_size == false)
                //{
                //    catalog.size = old_size;
                //}
                //if (c_cat == false)
                //{
                //    catalog.category = old_category;
                //}
                return(View(catalog));
            }