예제 #1
0
    public string GetOrganismTypeName(int organismTypeID)
    {
        OrganismTypeBLL organismTypeBLL = new OrganismTypeBLL();
        OrganismType    organismType    = organismTypeBLL.GetOrganismTypeByOrganismTypeID(organismTypeID);

        return(organismType.OrganismTypeName);
    }
예제 #2
0
    protected void ButtonDeleteSelected_Click(object sender, System.EventArgs e)
    {
        try
        {
            // Create a List to hold the OrganismTypeID values to delete
            List <Int32> OrganismTypeIDsToDelete = new List <Int32>();

            // Iterate through the OrganismTypes.Rows property
            foreach (GridViewRow row in gridViewOrganismTypes.Rows)
            {
                // Access the CheckBox
                CheckBox cb = (CheckBox)(row.FindControl("chkOrganismTypeSelector"));
                if (cb != null && cb.Checked)
                {
                    // Save the OrganismTypeID value for deletion
                    // First, get the OrganismTypeID for the selected row
                    Int32           OrganismTypeID  = (Int32)gridViewOrganismTypes.DataKeys[row.RowIndex].Value;
                    OrganismTypeBLL OrganismTypeBLL = new OrganismTypeBLL();
                    Eisk.BusinessEntities.OrganismType OrganismType = OrganismTypeBLL.GetOrganismTypeByOrganismTypeID(OrganismTypeID);

                    // Add it to the List...
                    OrganismTypeIDsToDelete.Add(OrganismTypeID);

                    // Add a confirmation message
                    ltlMessage.Text += String.Format(MessageFormatter.GetFormattedSuccessMessage("Delete successful. Organism Type <b>{0}</b> has been deleted"), OrganismType.OrganismTypeName);
                }
            }

            //perform the actual delete
            new OrganismTypeBLL().DeleteOrganismTypes(OrganismTypeIDsToDelete);
        }
        catch (Exception ex)
        {
            ltlMessage.Text = ExceptionManager.DoLogAndGetFriendlyMessageForException(ex);
        }

        //binding the grid
        gridViewOrganismTypes.PageIndex = 0;
        gridViewOrganismTypes.DataBind();
    }
예제 #3
0
    protected void FormViewOrganism_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        TextBox              txtCommonName     = (TextBox)formViewOrganism.FindControl("txtCommonName");
        TextBox              txtScientificName = (TextBox)formViewOrganism.FindControl("txtScientificName");
        DropDownList         ddlOrganismType   = (DropDownList)formViewOrganism.FindControl("ddlOrganismType");
        OrganismActionStatus status            = Validate(txtCommonName.Text, txtScientificName.Text, Convert.ToInt32(ddlOrganismType.SelectedValue), actionType.update);

        if (status == OrganismActionStatus.Success)
        {
            Type           myType = (typeof(Organism));
            PropertyInfo[] props  = myType.GetProperties();

            string[] arrNewValues = new string[e.NewValues.Keys.Count];
            e.NewValues.Keys.CopyTo(arrNewValues, 0);

            OrganismBLL     organismBLL     = new OrganismBLL();
            OrganismTypeBLL organismTypeBLL = new OrganismTypeBLL();
            OrganismType    organismType    = organismTypeBLL.GetOrganismTypeByOrganismTypeID(Convert.ToInt32(ddlOrganismType.SelectedValue));
            Organism        organism        = organismBLL.GetOrganismByOrganismId2((int)e.Keys["OrganismId"]);

            foreach (var prop in props)
            {
                if (("System.String,System.Int32,System.Int,System.DateTime,System.Guid").IndexOf((prop.PropertyType).FullName) >= 0) // Si la propiedad es de tipo Guid, String, Int o DateTime
                {
                    if (!arrNewValues.Contains(prop.Name))
                    {
                        e.NewValues[prop.Name] = prop.GetValue(organism, null);
                    }
                }
            }

            e.NewValues["OrganismTypeID"]            = organismType.OrganismTypeID;
            Page.RouteData.Values["organismtype_id"] = organismType.OrganismTypeID.ToString();
        }
        else
        {
            ltlMessage.Text = MessageFormatter.GetFormattedErrorMessage(GetErrorMessage(status));
            e.Cancel        = true;
        }
    }