Ejemplo n.º 1
0
        protected void ctlDeleteLocation_Click(object sender, ImageClickEventArgs e)
        {
            foreach (GridViewRow row in ctlLocationGrid.Rows)
            {
                if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
                {
                    try
                    {
                        long serviceTeamLocationId = UIHelper.ParseLong(ctlLocationGrid.DataKeys[row.RowIndex]["ServiceTeamLocationID"].ToString());
                        DbServiceTeamLocation serviceTeamLocation = ScgDbQueryProvider.DbServiceTeamLocationQuery.FindByIdentity(serviceTeamLocationId);
                        DbServiceTeamLocationService.Delete(serviceTeamLocation);
                    }
                    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);

                            ctlUpdatePanelLocationGrid.Update();
                        }
                    }
                }
            }
            ctlLocationGrid.DataCountAndBind();
            ctlUpdatePanelLocationGrid.Update();
        }
Ejemplo n.º 2
0
        protected void ctlLocationLookup_OnObjectLookUpReturn(object sender, ObjectLookUpReturnArgs e)
        {
            IList <DbLocation>            locationList            = (IList <DbLocation>)e.ObjectReturn;
            IList <DbServiceTeamLocation> serviceTeamLocationList = new List <DbServiceTeamLocation>();

            foreach (DbLocation location in locationList)
            {
                Location locate = new Location();
                locate.LocationID = location.LocationID;
                DbServiceTeam         serviceTeam         = ScgDbQueryProvider.DbServiceTeamQuery.FindByIdentity(Convert.ToInt64(ctlServiceTeamIDHidden.Value));
                DbServiceTeamLocation serviceTeamLocation = GetServiceTeamLocation(serviceTeam, locate);
                serviceTeamLocationList.Add(serviceTeamLocation);
            }

            if (serviceTeamLocationList.Count > 0)
            {
                try
                {
                    DbServiceTeamLocationService.AddServiceTeamLocationList(serviceTeamLocationList);
                    ctlLocationGrid.DataCountAndBind();
                }
                catch (ServiceValidationException ex)
                {
                    ValidationErrors.MergeErrors(ex.ValidationErrors);
                }
            }
            ctlUpdatePanelLocationGrid.Update();
        }