protected void btnCTSave_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                var obj = new CodeType();
                var isEdit = false;
                int pk = 0;
                if (CTID.Text != "")
                {
                    pk = int.Parse(CTID.Text);
                    obj.Fetch(pk);
                    isEdit = true;
                }

                if (!isEdit) obj.isSystem = false;
                obj.Description = CodeTypeDesc.Text;
                obj.CodeTypeName = CodeTypeValue.Text;

                if (isEdit)
                {
                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();
                        LoadData();
                        ShowDD();

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.SaveOK;
                    }
                    else
                    {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }
                }
                else
                {
                    if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                    {
                        pk = obj.Insert();
                        LoadData();
                        ddlCodeTypes.SelectedValue = pk.ToString();
                        ShowDD();

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.AddedOK;
                    }
                    else
                    {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }                    
                }
                
            }
            catch (Exception ex)
            {
                var masterPage = (IControlRoomMaster)Master;
                masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
            }
        }