示例#1
0
        protected void PostBack()
        {
            Item firstItem = new Item();

            firstItem = POC.GetDefaultItem();
            List <Item> ItemList = new List <Item>();

            ItemList.Add(firstItem);
            Session["ItemList"]            = ItemList;
            GridViewCreateOrder.DataSource = ItemList;
            GridViewCreateOrder.DataBind();
        }
示例#2
0
 protected void GridViewCreateOrder_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteItem")
     {
         int           index    = Convert.ToInt32(e.CommandArgument);
         TextBox       tbQty    = new TextBox();
         TextBox       tbUOM    = new TextBox();
         DropDownList  drpItem  = new DropDownList();
         DropDownList  drpDesc  = new DropDownList();
         DropDownList  drpCate  = new DropDownList();
         List <string> QtyList  = new List <string>();
         List <Item>   ItemList = new List <Item>();
         ItemList.Clear();
         QtyList.Clear();
         if (GridViewCreateOrder.Rows.Count == 1)
         {
             Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Order should has at least one item! ')</script>");
         }
         else
         {
             for (int i = 0; i < GridViewCreateOrder.Rows.Count; i++)
             {
                 drpItem = (DropDownList)GridViewCreateOrder.Rows[i].Cells[1].FindControl("DropDownListItemCode");
                 Item additem = POC.GetItemByItem_ID(drpItem.SelectedValue);
                 ItemList.Add(additem);
                 tbQty = (TextBox)GridViewCreateOrder.Rows[i].Cells[3].FindControl("TextboxQty");
                 QtyList.Add(tbQty.Text);
             }
             ItemList.RemoveAt(index);
             QtyList.RemoveAt(index);
             Session["ItemList"]            = ItemList;
             GridViewCreateOrder.DataSource = ItemList;
             GridViewCreateOrder.DataBind();
             for (int i = 0; i < QtyList.Count; i++)
             {
                 tbQty      = (TextBox)GridViewCreateOrder.Rows[i].Cells[3].FindControl("TextboxQty");
                 tbQty.Text = QtyList[i];
             }
             for (int i = 0; i < GridViewCreateOrder.Rows.Count; i++)
             {
                 drpItem = (DropDownList)GridViewCreateOrder.Rows[i].Cells[1].FindControl("DropDownListItemCode");
                 drpDesc = (DropDownList)GridViewCreateOrder.Rows[i].Cells[2].FindControl("DropDownListDesc");
                 drpCate = (DropDownList)GridViewCreateOrder.Rows[i].Cells[0].FindControl("DropDownListCategory");
                 tbUOM   = (TextBox)GridViewCreateOrder.Rows[i].Cells[4].FindControl("TextboxUOM");
                 drpItem.SelectedValue = ItemList[i].Item_ID;
                 drpCate.SelectedValue = ItemList[i].ItemCategory.Category_ID;
                 drpDesc.SelectedValue = ItemList[i].Item_Name;
                 tbUOM.Text            = ItemList[i].UOM;
             }
         }
     }
 }
示例#3
0
        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            TextBox       tbQty    = new TextBox();
            TextBox       tbUOM    = new TextBox();
            DropDownList  drpItem  = new DropDownList();
            DropDownList  drpDesc  = new DropDownList();
            DropDownList  drpCate  = new DropDownList();
            List <string> QtyList  = new List <string>();
            List <Item>   ItemList = new List <Item>();
            Item          newItem  = new Item();

            ItemList.Clear();
            QtyList.Clear();
            for (int i = 0; i < GridViewCreateOrder.Rows.Count; i++)
            {
                drpItem = (DropDownList)GridViewCreateOrder.Rows[i].Cells[1].FindControl("DropDownListItemCode");
                Item additem = POC.GetItemByItem_ID(drpItem.SelectedValue);
                ItemList.Add(additem);
                tbQty = (TextBox)GridViewCreateOrder.Rows[i].Cells[3].FindControl("TextboxQty");
                QtyList.Add(tbQty.Text);
            }
            newItem = POC.GetDefaultItem();
            ItemList.Add(newItem);
            Session["ItemList"]            = ItemList;
            GridViewCreateOrder.DataSource = ItemList;
            GridViewCreateOrder.DataBind();

            for (int i = 0; i < QtyList.Count; i++)
            {
                tbQty      = (TextBox)GridViewCreateOrder.Rows[i].Cells[3].FindControl("TextboxQty");
                tbQty.Text = QtyList[i];
            }
            for (int i = 0; i < GridViewCreateOrder.Rows.Count; i++)
            {
                drpItem = (DropDownList)GridViewCreateOrder.Rows[i].Cells[1].FindControl("DropDownListItemCode");
                drpDesc = (DropDownList)GridViewCreateOrder.Rows[i].Cells[2].FindControl("DropDownListDesc");
                drpCate = (DropDownList)GridViewCreateOrder.Rows[i].Cells[0].FindControl("DropDownListCategory");
                tbUOM   = (TextBox)GridViewCreateOrder.Rows[i].Cells[4].FindControl("TextboxUOM");
                drpItem.SelectedValue = ItemList[i].Item_ID;
                drpCate.SelectedValue = ItemList[i].ItemCategory.Category_ID;
                drpDesc.SelectedValue = ItemList[i].Item_Name;
                tbUOM.Text            = ItemList[i].UOM;
            }
        }