Exemplo n.º 1
0
        protected void ctlServiceTeamForm_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            short    serviceTeamId      = Convert.ToInt16(ctlServiceTeamForm.DataKey.Value);
            TextBox  ctlServiceTeamCode = (TextBox)ctlServiceTeamForm.FindControl("ctlServiceTeamCode");
            TextBox  ctlDescription     = (TextBox)ctlServiceTeamForm.FindControl("ctlDescription");
            CheckBox ctlActiveChk       = (CheckBox)ctlServiceTeamForm.FindControl("ctlActiveChk");

            DbServiceTeam serviceTeam = DbServiceTeamService.FindByIdentity(serviceTeamId);

            serviceTeam.ServiceTeamCode = ctlServiceTeamCode.Text;
            serviceTeam.Description     = ctlDescription.Text;

            serviceTeam.Active  = ctlActiveChk.Checked;
            serviceTeam.CreBy   = UserAccount.UserID;
            serviceTeam.CreDate = DateTime.Now;
            serviceTeam.UpdBy   = UserAccount.UserID;
            serviceTeam.UpdDate = DateTime.Now;
            serviceTeam.UpdPgm  = ProgramCode;

            try
            {
                DbServiceTeamService.UpdateServiceTeam(serviceTeam);
                ctlServiceTeamGrid.DataCountAndBind();
                ctlServiceTeamForm.ChangeMode(FormViewMode.ReadOnly);
                CloseServiceTeamPopUp();
            }
            catch (ServiceValidationException ex)
            {
                ValidationErrors.MergeErrors(ex.ValidationErrors);
            }
        }
Exemplo n.º 2
0
        protected void ctlServiceTeamGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("ServiceTeamEdit"))
            {
                int   rowIndex      = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                short serviceTeamId = Convert.ToInt16(ctlServiceTeamGrid.DataKeys[rowIndex].Value);
                ctlServiceTeamForm.PageIndex = (ctlServiceTeamGrid.PageIndex * ctlServiceTeamGrid.PageSize) + rowIndex;
                ctlServiceTeamForm.ChangeMode(FormViewMode.Edit);
                IList <DbServiceTeam> serviceTeamList = new List <DbServiceTeam>();
                DbServiceTeam         serviceTeam     = DbServiceTeamService.FindByIdentity(serviceTeamId);
                serviceTeamList.Add(serviceTeam);
                ctlServiceTeamForm.DataSource = serviceTeamList;
                ctlServiceTeamForm.DataBind();

                ctlUpdatePanelServiceTeamForm.Update();
                ctlServiceTeamModalPopupExtender.Show();
            }
            if (e.CommandName.Equals("ServiceTeamDelete"))
            {
                try
                {
                    int           rowIndex      = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                    long          serviceTeamId = UIHelper.ParseLong(ctlServiceTeamGrid.DataKeys[rowIndex].Value.ToString());
                    DbServiceTeam serviceTeam   = ScgDbQueryProvider.DbServiceTeamQuery.FindByIdentity(serviceTeamId);
                    DbServiceTeamService.Delete(serviceTeam);
                }
                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);
                        ctlServiceTeamGrid.DataCountAndBind();
                    }
                }
                ctlServiceTeamGrid.DataCountAndBind();
                ctlUpdatePanelServiceTeamGridview.Update();
            }
            if (e.CommandName.Equals("LocationEdit"))
            {
                int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                ctlServiceTeamGrid.SelectedIndex = rowIndex;
                long serviceTeamId = UIHelper.ParseShort(ctlServiceTeamGrid.DataKeys[rowIndex].Value.ToString());
                ctlServiceTeamIDHidden.Value = serviceTeamId.ToString();

                ctlLocationGrid.DataCountAndBind();

                lblLocationHeader.Visible = true;
                ctlLocationGrid.Visible   = true;
                ctlLocationTools.Visible  = true;
                ctlAddLocation.Visible    = true;
                ctlCloseLocation.Visible  = true;
                ctlUpdatePanelServiceTeamGridview.Update();
                ctlUpdatePanelLocationGrid.Update();
            }
        }
Exemplo n.º 3
0
        protected void ctlServiceTeamForm_DataBound(object sender, EventArgs e)
        {
            if (ctlServiceTeamForm.CurrentMode != FormViewMode.ReadOnly)
            {
                TextBox ctlServiceTeamCode = (TextBox)ctlServiceTeamForm.FindControl("ctlServiceTeamCode");
                ctlServiceTeamCode.Focus();
                CheckBox ctlActiveCheck = (CheckBox)ctlServiceTeamForm.FindControl("ctlActiveChk");

                if (ctlServiceTeamForm.CurrentMode == FormViewMode.Edit)
                {
                    short         serviceTeamID = UIHelper.ParseShort(ctlServiceTeamForm.DataKey.Value.ToString());
                    DbServiceTeam serviceTeam   = DbServiceTeamService.FindByIdentity(serviceTeamID);
                }
                if (ctlServiceTeamForm.CurrentMode == FormViewMode.Insert)
                {
                    ctlActiveCheck.Checked = true;
                }
            }
        }