Example #1
0
    private void Save()
    {
        ContainerType type = null;

        if (txtTypeCode.Visible)
        {
            type = new ContainerType(Convert.ToChar(txtTypeCode.Text), txtTypeName.Text, cbIsResource.Checked);
        }
        else
        {
            type = ContainerType.GetByKey(Convert.ToChar(txtTypeCodeDisable.Text));
            if (type != null)
            {
                type.Name       = txtTypeName.Text;
                type.IsResource = cbIsResource.Checked;
            }
        }
        if (type != null)
        {
            if (type.Save(txtTypeCodeDisable.Text == string.Empty))
            {
                SessionState.ClearAppContainerTypes();
                if (txtTypeCode.Visible)
                {
                    // Create new container type
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script>back();</script>");
                }
                else
                {
                    // Update container type
                    lbError.Text     = "Data saved!";
                    lbError.CssClass = "hc_success";
                    lbError.Visible  = true;
                }
            }
            else
            {
                lbError.CssClass = "hc_error";
                lbError.Text     = ContainerType.LastError;
                lbError.Visible  = true;
            }
        }
        else
        {
            lbError.CssClass = "hc_error";
            lbError.Text     = "Error: Container type is null";
            lbError.Visible  = true;
        }
    }