Пример #1
0
        protected void OnButtonDeleteClicked(object sender, EventArgs e)
        {
            TreeIter iter;

            treeviewUsers.Selection.GetSelected (out iter);
            int itemid = (int)UsersListStore.GetValue (iter, 0);
            string loginname = UsersListStore.GetValue (iter, 1).ToString ();
            bool result;
            if (QSMain.IsOrmDeletionConfigered) {
                result = QSMain.OnOrmDeletion ("users", itemid);
            } else {
                Delete winDel = new Delete ();
                result = winDel.RunDeletion ("users", itemid);
                winDel.Destroy ();
            }

            if (result) {
                logger.Info ("Удаляем пользователя MySQL...");
                if (QSSaaS.Session.IsSaasConnection) {
                    QSSaaS.ISaaSService svc = QSSaaS.Session.GetSaaSService ();
                    if (!svc.changeBaseAccessFromProgram (QSSaaS.Session.SessionId, loginname, QSSaaS.Session.SaasBaseName, false))
                        logger.Error ("Ошибка удаления доступа к базе на сервере SaaS.");
                } else {
                    string sql;
                    sql = "DROP USER @login, @login @'localhost'";
                    try {
                        QSMain.CheckConnectionAlive ();
                        MySqlCommand cmd = new MySqlCommand (sql, QSMain.connectionDB);
                        cmd.Parameters.AddWithValue ("@login", loginname);
                        cmd.ExecuteNonQuery ();
                        logger.Info ("Пользователь удалён. Ok");

                        if (QSMain.User.Id == itemid) {
                            MessageDialog md = new MessageDialog (this, DialogFlags.DestroyWithParent,
                                                   MessageType.Warning, ButtonsType.Close,
                                                   "Был удален пользователь, под которым Вы подключились к базе данных, чтобы недопустить некорректных операций программа закроется. Зайдите в программу от имени другого пользователя.");
                            md.Run ();
                            md.Destroy ();
                            Environment.Exit (0);
                        }
                    } catch (Exception ex) {
                        logger.Error (ex, "Ошибка удаления пользователя!");
                        QSMain.ErrorMessage (this, ex);
                    }
                }
            }

            UpdateUsers ();
        }
Пример #2
0
 protected void OnButtonDeleteClicked(object sender, EventArgs e)
 {
     Delete winDelete = new Delete();
     if (winDelete.RunDeletion("orders", Item_id))
         Respond(ResponseType.Ok);
 }
Пример #3
0
        protected void OnRemoveActionActivated(object sender, System.EventArgs e)
        {
            TreeIter iter;
            treeviewref.Selection.GetSelected(out iter);
            SelectedID = (int) filter.GetValue(iter, 0);
            bool result;
            if (QSMain.IsOrmDeletionConfigered) {
                result = QSMain.OnOrmDeletion (TableRef, SelectedID);
            } else {
                Delete winDelete = new Delete();
                result = winDelete.RunDeletion (TableRef, SelectedID);
                winDelete.Destroy();
            }

            if(result)
            {
                UpdateList();
                RefChanged = true;
            }
        }
Пример #4
0
 protected void OnButtonDeleteReadingClicked(object sender, EventArgs e)
 {
     TreeIter iter;
     Meters[notebookMeters.CurrentPage].treeview.Selection.GetSelected (out iter);
     int itemid = (int) Meters [notebookMeters.CurrentPage].treeview.Model.GetValue (iter, 0);
     Delete winDelete = new Delete();
     if(winDelete.RunDeletion("meter_reading", itemid))
         UpdateReadings();
 }
Пример #5
0
 protected void OnButtonDeleteMeterClicked(object sender, EventArgs e)
 {
     int itemid = Meters[notebookMeters.CurrentPage].ID;
     Delete winDelete = new Delete();
     if(winDelete.RunDeletion("meters", itemid))
         UpdateMeters();
 }
Пример #6
0
 protected void OnButtonDeleteClicked(object sender, EventArgs e)
 {
     TreeIter iter;
     treeviewTariff.Selection.GetSelected (out iter);
     if ((int)TariffListStore.GetValue (iter, 0) > 0)
     {
         int itemid = (int)TariffListStore.GetValue (iter, 0);
         Delete winDelete = new Delete();
         if(winDelete.RunDeletion("meter_tariffs", itemid))
             TariffListStore.Remove(ref iter);
     }
     else
     {
         TariffListStore.Remove(ref iter);
     }
     TestCanSave ();
     OnTreeviewTariffCursorChanged (null, null);
 }