Ejemplo n.º 1
0
 protected void gvDupes_RowCommand(Object sender, CommandEventArgs e)
 {
     if (e != null && String.Compare(e.CommandName, "_Use", StringComparison.OrdinalIgnoreCase) == 0)
     {
         MakeID = Convert.ToInt32(e.CommandArgument, CultureInfo.InvariantCulture);
         ClearDupes();
         MakeUpdated?.Invoke(sender, e);
     }
 }
Ejemplo n.º 2
0
    protected void CommitChanges(object sender, EventArgs e, Boolean fIgnoreDupes)
    {
        if (!Page.IsValid)
        {
            return;
        }

        Model = MakeFromForm();

        if (!fIgnoreDupes && MakeID < 0)
        {
            MakeModel[] rgmmDupes = Model.PossibleMatches();
            if (rgmmDupes.Length > 0)
            {
                gvDupes.DataSource = rgmmDupes;
                gvDupes.DataBind();
                modalPopupDupes.Show();
                return;
            }
        }

        // If this is a new make, inherit the manufacturer's sim-only status.
        if (MakeID == -1) // creation event
        {
            Model.AllowedTypes = (new Manufacturer(Model.ManufacturerID)).AllowedTypes;
        }

        try
        {
            string szOriginalDesc = string.Empty;
            bool   fIsNew         = Model.IsNew;
            if (!fIsNew)
            {
                szOriginalDesc = new MakeModel(MakeID).ToString();
            }

            Model.Commit();

            // use fIsNew because Model.IsNew may have been true and not now.
            string szLinkEditModel = String.Format(CultureInfo.InvariantCulture, "{0}?id={1}", "~/Member/EditMake.aspx".ToAbsoluteURL(Request), Model.MakeModelID);
            string szNewDesc       = Model.ToString();
            if (fIsNew)
            {
                util.NotifyAdminEvent("New Model created", String.Format(CultureInfo.InvariantCulture, "User: {0}\r\n\r\n{1}\r\n{2}", MyFlightbook.Profile.GetUser(Page.User.Identity.Name).DetailedName, szNewDesc, szLinkEditModel), ProfileRoles.maskCanManageData);
            }
            else
            {
                if (String.Compare(szNewDesc, szOriginalDesc, StringComparison.Ordinal) != 0)
                {
                    util.NotifyAdminEvent("Model updated", String.Format(CultureInfo.InvariantCulture, "User: {0}\r\n\r\nWas:\r\n{1}\r\n\r\nIs Now: \r\n{2}\r\n \r\nID: {3}, {4}",
                                                                         MyFlightbook.Profile.GetUser(Page.User.Identity.Name).DetailedName,
                                                                         szOriginalDesc,
                                                                         szNewDesc,
                                                                         Model.MakeModelID, szLinkEditModel), ProfileRoles.maskCanManageData);
                }
            }

            MakeID = Model.MakeModelID;

            ClearDupes();
            MakeUpdated?.Invoke(sender, e);
        }
        catch (MyFlightbookException ex)
        {
            lblError.Text = ex.Message;
        }
    }