Beispiel #1
0
        void Save(Object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(txtName.Text))
                {
                    MessageUtil.Warn("Invalid ShortCut Name!..");
                    return;
                }

                if (String.IsNullOrWhiteSpace(txtPath.Text))
                {
                    MessageUtil.Warn("Invalid ShortCut Path!..");
                    return;
                }

                if (shortcutId > 0)
                {
                    Kisayol ks = AppVariables.GetById(shortcutId);
                    ks.Yol        = txtPath.Text;
                    ks.KisayolAdi = txtName.Text;
                    int i = SQLiteManager.Update(ks);
                    //ks.Update();
                    AppVariables.Update(ks);
                    if (i == 1)
                    {
                        this.DialogResult = DialogResult.OK;
                        return;
                    }

                    MessageUtil.Error("Update is failed.");
                    this.DialogResult = DialogResult.Abort;
                    return;
                }
                else
                {
                    Kisayol ks = AppVariables.GetByName(txtName.Text);
                    if (ks != null)
                    {
                        MessageUtil.Warn("There is already a Shortcut with given name, please write another name!..");
                        return;
                    }
                    ks            = new Kisayol();
                    ks.Yol        = txtPath.Text;
                    ks.KisayolAdi = txtName.Text;
                    ks.Tarih      = DateTime.Now;
                    int _retInt = SQLiteManager.Add(ks);
                    //ks.Add();
                    if (_retInt == 1)
                    {
                        ks.Id = SQLiteManager.GetIdentity();
                        AppVariables.Add(ks);
                        this.DialogResult = DialogResult.OK;
                        return;
                    }

                    this.DialogResult = DialogResult.Abort;
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageUtil.Error("ShortCut could not be saved.");
                Logger.WriteException(ex, "ShortCutSave", "ShortCut could not be saved.");
            }
        }