protected void uiGridViewItems_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditItem") { IStock.BLL.Items objData = new IStock.BLL.Items(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); uiTextBoxName.Text = objData.Name; uiTextBoxCode.Text = objData.ItemCode; uiTextBoxDesc.Text = objData.Description; if (!objData.IsColumnNull("Quantity")) uiTextBoxQty.Text = objData.Quantity.ToString(); if(!objData.IsColumnNull("ReOrderLevel")) uiTextBoxReOrderLevel.Text = objData.ReOrderLevel.ToString(); IStock.BLL.ItemGroups group = new IStock.BLL.ItemGroups(); group.LoadByPrimaryKey(Convert.ToInt32(objData.GroupID)); uiLabelGroup.Text = group.Name; IStock.BLL.ItemCategories cat = new ItemCategories(); if (!string.IsNullOrEmpty(uiDropDownListCats.SelectedValue)) { cat.LoadByPrimaryKey(Convert.ToInt32(uiDropDownListCats.SelectedValue)); } else cat.LoadByPrimaryKey(group.ItemCategoryID); uiLabelCat.Text = cat.Name; uiPanelAllItems.Visible = false; uiPanelEditItems.Visible = true; CurrentItem = objData; BindPrices(); uiPanelActions.Visible = true; } else if (e.CommandName == "DeleteItem") { try { IStock.BLL.Items objData = new IStock.BLL.Items(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); objData.MarkAsDeleted(); objData.Save(); CurrentItem = null; BindData(); } catch (Exception ex) { uipanelError.Visible = true; } } else if (e.CommandName == "GetItemBalance") { Session["Report_ItemIDForBalance"] = e.CommandArgument.ToString(); Session["CurrentReport"] = "Report_GetItemsBalances"; Response.Redirect("Reports.aspx"); } }
protected void uiLinkButtonOK_Click(object sender, EventArgs e) { IStock.BLL.Items item = new IStock.BLL.Items(); if (CurrentItem == null) item.AddNew(); else item = CurrentItem; item.Name = uiTextBoxName.Text; item.Description = uiTextBoxDesc.Text; if(!string.IsNullOrEmpty(uiTextBoxQty.Text)) item.Quantity = Convert.ToInt32(uiTextBoxQty.Text); item.ItemCode = uiTextBoxCode.Text; item.GroupID = Convert.ToInt32(uiDropDownListGroup.SelectedValue); if (!string.IsNullOrEmpty(uiTextBoxReOrderLevel.Text)) item.ReOrderLevel = Convert.ToInt32(uiTextBoxReOrderLevel.Text); item.Save(); //ClearFields(); CurrentItem = item; uiPanelEditItems.Visible = true; uiPanelAllItems.Visible = false; BindData(); BindPrices(); uiPanelActions.Visible = true; }