Exemple #1
0
        public List <Virus_Item> UpdateCartItems()
        {
            using (VirusDescriptionActions usersShoppingCart = new VirusDescriptionActions())
            {
                String virusId = usersShoppingCart.GetVirusId();
                VirusDescriptionActions.VirusDescriptionUpdates[] cartUpdates = new VirusDescriptionActions.VirusDescriptionUpdates[DescriptionList.Rows.Count];
                for (int i = 0; i < DescriptionList.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(DescriptionList.Rows[i]);
                    cartUpdates[i].AttributeId = Convert.ToInt32(rowValues["AttributeID"]);

                    CheckBox cbRemove = new CheckBox();
                    cbRemove = (CheckBox)DescriptionList.Rows[i].FindControl("Remove");
                    cartUpdates[i].RemoveItem = cbRemove.Checked;

                    CheckBox cbOnOff = new CheckBox();
                    cbOnOff = (CheckBox)DescriptionList.Rows[i].FindControl("On_Off_CheckBox");
                    if (cbOnOff.Checked == true)                                                      //Check to see if On/off is checked
                    {
                        if (usersShoppingCart.Get_OnOff(virusId, cartUpdates[i].AttributeId) == true) //If checked and currently on, turn off
                        {
                            cartUpdates[i].OnOff = false;
                        }
                        else //If checked and currently off, turn on
                        {
                            cartUpdates[i].OnOff = true;
                        }
                        //cartUpdates[i].OnOff = cbOnOff.Checked;
                    }
                    else //if not checked, query DB for previous state
                    {
                        cartUpdates[i].OnOff = usersShoppingCart.Get_OnOff(virusId, cartUpdates[i].AttributeId);
                    }
                    //cartUpdates[i].OnOff = cbOnOff.Checked;
                }
                usersShoppingCart.UpdateVirusDescriptionDatabase(virusId, cartUpdates);
                DescriptionList.DataBind();
                lblTotal.Text      = String.Format("{0:d}", usersShoppingCart.GetCount());
                lblTotalF_in.Text  = String.Format("{0:d}", usersShoppingCart.getTotalF_in());
                lblTotalF_out.Text = String.Format("{0:d}", usersShoppingCart.getTotalF_out());
                return(usersShoppingCart.GetDescriptionItems());
            }
        }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (VirusDescriptionActions usersVirus = new VirusDescriptionActions())
     {
         int totalNumberofAttributes = 0;
         int totalF_in  = 0;
         int totalF_out = 0;
         //Built = false;
         //Built = getBuiltStatus();
         totalNumberofAttributes = usersVirus.GetCount();
         totalF_in  = usersVirus.getTotalF_in();
         totalF_out = usersVirus.getTotalF_out();
         if (!Built)
         {
             abstractionNone.Visible = abstractionGrid.Visible = abstractionResults.Visible = false;
             directNone.Visible      = direct.Visible = directGrid.Visible = false;
             indirectNone.Visible    = indirectGrid.Visible = indirect.Visible = false;
             ColumnGrid.Visible      = ColumnResults.Visible = false;
             RowGrid.Visible         = RowResults.Visible = false;
         }
         if (totalNumberofAttributes > 0)
         {
             // Display Total.
             VirusDescriptionTitle.Visible = true;
             NoSelected.Visible            = false;
             UpdateBtn.Visible             = true;
             BuildCombo.Visible            = true;
             BuildRow.Visible = true;
             BuildCol.Visible = true;
             ClearBtn.Visible = true;
             lblTotal.Text    = String.Format("{0:d}", totalNumberofAttributes);
             VirusDescriptionTitle.InnerText = "Current Virus Total";
             if (totalF_in > 0)
             {
                 lblTotalF_in.Text = String.Format("{0:d}", totalF_in);
             }
             else
             {
                 lblTotalF_in.Text = "0";
             }
             if (totalF_out > 0)
             {
                 lblTotalF_out.Text = String.Format("{0:d}", totalF_out);
             }
             else
             {
                 lblTotalF_out.Text = "0";
             }
         }
         else
         {
             VirusDescriptionTitle.Visible = false;
             NoSelected.Visible            = true;
             LabelTotalText.Text           = "";
             lblTotal.Text           = "";
             LabelTotalF_in.Text     = "";
             lblTotalF_in.Text       = "";
             LabelTotalF_out.Text    = "";
             lblTotalF_out.Text      = "";
             UpdateBtn.Visible       = false;
             BuildCombo.Visible      = false;
             BuildRow.Visible        = false;
             BuildCol.Visible        = false;
             ClearBtn.Visible        = false;
             abstractionNone.Visible = abstractionResults.Visible = abstractionGrid.Visible = false;
             directNone.Visible      = direct.Visible = directGrid.Visible = false;
             indirectNone.Visible    = indirectGrid.Visible = indirect.Visible = false;
             RowResults.Visible      = RowGrid.Visible = false;
             ColumnResults.Visible   = ColumnGrid.Visible = false;
         }
     }
 }