protected void btnCodeSave_Click(object sender, ImageClickEventArgs e)
        {
            var  rptr   = rptrCodes;
            int  i      = 0;
            bool errors = false;

            foreach (RepeaterItem item in rptr.Items)
            {
                i++;
                try
                {
                    var CID         = int.Parse(((TextBox)item.FindControl("CID")).Text);
                    var CTID        = int.Parse(((TextBox)item.FindControl("CTID")).Text);
                    var Code        = ((TextBox)item.FindControl("Code")).Text;
                    var Description = ((TextBox)item.FindControl("Description")).Text;

                    var obj = new DAL.Codes();
                    obj.Fetch(CID);
                    obj.Code        = Code;
                    obj.Description = Description;

                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();


                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.SaveAllOK;
                    }
                    else
                    {
                        var    masterPage = (IControlRoomMaster)Master;
                        string message    = String.Format("On Row {1}: " + SRPResources.ApplicationError1, "<ul>", i);
                        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;
                        errors = true;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format("On Row {1}: " + SRPResources.ApplicationError1, ex.Message, i);
                    errors = true;
                }
            }

            if (!errors)
            {
                ShowDD();
            }
        }
        protected void btnCodeSave_Click(object sender, ImageClickEventArgs e)
        {
            var rptr = rptrCodes;
            int i = 0;
            bool errors = false;
            foreach (RepeaterItem item in rptr.Items)
            {

                i++;
                try
                {
                    var CID = int.Parse(((TextBox)item.FindControl("CID")).Text);
                    var CTID = int.Parse(((TextBox)item.FindControl("CTID")).Text);
                    var Code = ((TextBox)item.FindControl("Code")).Text;
                    var Description = ((TextBox)item.FindControl("Description")).Text;

                    var obj = new DAL.Codes();
                    obj.Fetch(CID);
                    obj.Code = Code;
                    obj.Description = Description;

                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();
                        

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.SaveAllOK;
                    }
                    else
                    {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format("On Row {1}: " + SRPResources.ApplicationError1, "<ul>", i);
                        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;
                        errors = true;
                    }


                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format("On Row {1}: " + SRPResources.ApplicationError1, ex.Message, i);
                    errors = true;
                }

            }

            if (!errors) ShowDD();
        }