protected void ctlProgramForm_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            short    programId      = Convert.ToInt16(ctlProgramForm.DataKey.Value);
            TextBox  ctlProgramCode = (TextBox)ctlProgramForm.FindControl("ctlProgramCode");
            TextBox  ctlComment     = (TextBox)ctlProgramForm.FindControl("ctlComment");
            CheckBox ctlActiveChk   = (CheckBox)ctlProgramForm.FindControl("ctlActiveChk");

            SuProgram program = SuProgramService.FindByIdentity(programId);

            program.ProgramCode = ctlProgramCode.Text;
            program.Comment     = ctlComment.Text;
            program.Active      = ctlActiveChk.Checked;
            program.UpdBy       = UserAccount.UserID;
            program.UpdDate     = DateTime.Now;
            program.UpdPgm      = ProgramCode;
            try
            {
                SuProgramService.UpdateProgram(program);
                ctlProgramGrid.DataCountAndBind();
                ctlProgramForm.ChangeMode(FormViewMode.ReadOnly);
                ClosePopUp();
            }
            catch (ServiceValidationException ex)
            {
                ValidationErrors.MergeErrors(ex.ValidationErrors);
            }
        }
 protected void ctlDelete_Click(object sender, ImageClickEventArgs e)
 {
     foreach (GridViewRow row in ctlProgramGrid.Rows)
     {
         if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelectChk")).Checked))
         {
             try
             {
                 short     programId = Convert.ToInt16(ctlProgramGrid.DataKeys[row.RowIndex].Value);
                 SuProgram program   = SuProgramService.FindByIdentity(programId);
                 SuProgramService.Delete(program);
             }
             catch (Exception ex)
             {
                 if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                 {
                     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                                                             "alert('This data is now in use.');", true);
                     ctlProgramGrid.DataCountAndBind();
                     ctlUpdatePanelGridview.Update();
                 }
             }
         }
     }
     ProgramLangGridViewFinish();
     ctlProgramGrid.DataCountAndBind();
     ctlUpdatePanelGridview.Update();
 }
        protected void ctlProgramGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "UserEdit")
            {
                int   rowIndex  = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                short programId = Convert.ToInt16(ctlProgramGrid.DataKeys[rowIndex].Value);
                ctlProgramForm.PageIndex = (ctlProgramGrid.PageIndex * ctlProgramGrid.PageSize) + rowIndex;
                ctlProgramForm.ChangeMode(FormViewMode.Edit);
                IList <SuProgram> programList = new List <SuProgram>();
                SuProgram         program     = SuProgramService.FindByIdentity(programId);
                programList.Add(program);

                ctlProgramForm.DataSource = programList;
                ctlProgramForm.DataBind();
                ctlProgramGrid.DataCountAndBind();

                UpdatePanelProgramForm.Update();
                ctlProgramModalPopupExtender.Show();
            }
            if (e.CommandName == "Select")
            {
                int   rowIndex  = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                short programId = UIHelper.ParseShort(ctlProgramGrid.DataKeys[rowIndex].Value.ToString());
                ctlProgramLanguageGrid.DataSource = SuProgramLangService.FindByProgramId(programId);
                ctlProgramLanguageGrid.DataBind();
                if (ctlProgramLanguageGrid.Rows.Count > 0)
                {
                    ctlSubmit.Visible         = true;
                    ctlProgramLangFds.Visible = true;
                    ctlCancel.Visible         = true;
                }
                else
                {
                    ctlSubmit.Visible         = false;
                    ctlProgramLangFds.Visible = false;
                    ctlCancel.Visible         = false;
                }
                ctlProgramGrid.DataCountAndBind();
                ctlProgramLanguageUpdatePanel.Update();
            }
        }