Exemple #1
0
        protected void btnAddType_Click(object sender, EventArgs e)
        {
            //check for the ID
            typeID = Request.QueryString["typeID"];
            bool        success = false;
            ProductType type    = new ProductType();

            try
            {
                if (lblNewTypeHeader.Text == "Edit Type")
                {
                    type.typeID = typeID;
                }
                else if (lblNewTypeHeader.Text == "New Type")
                {
                    type.typeID = function.GenerateRandomServiceTypeID();
                }
                type.name             = txtTypeName.Text;
                type.ProductOrService = 'S';

                if (btnAddType.Text == "Create Type")
                {
                    //add
                    success = handler.addProductType(type);
                    typeID  = type.typeID;
                }
                else if (btnAddType.Text == "Save")
                {
                    //edit
                    success = handler.editProductType(type);
                    typeID  = type.typeID;
                }
            }
            catch (Exception err)
            {
                if (btnAddType.Text == "Save")
                {
                    function.logAnError("Error editing service Type typeID=" + typeID + " | Error: " + err);
                    Response.Redirect("http://sict-iis.nmmu.ac.za/beauxdebut/error.aspx?Error=An%20error%20occurred%20updating%20Service%20Type");
                }
                else if (btnAddType.Text == "Create Type")
                {
                    function.logAnError("Error creating new type | Error: " + err);
                    Response.Redirect("http://sict-iis.nmmu.ac.za/beauxdebut/error.aspx?Error=An%20error%20occurred%20creating%20Service%20Type");
                }
            }

            if (success == true)
            {
                btnViewServiceTypes_Click(sender, e);
            }
            else if (success == false)
            {
                if (btnAddType.Text == "Save")
                {
                    function.logAnError("Error editing service Type typeID=" + typeID);
                    Response.Redirect("http://sict-iis.nmmu.ac.za/beauxdebut/error.aspx?Error=An%20error%20occurred%20updating%20Service%20Type");
                }
                else if (btnAddType.Text == "Create Type")
                {
                    function.logAnError("Error creating new type | Error: ");
                    Response.Redirect("http://sict-iis.nmmu.ac.za/beauxdebut/error.aspx?Error=An%20error%20occurred%20creating%20Service%20Type");
                }
            }
        }