Exemplo n.º 1
0
        public Result ShowPopupModal(System.Windows.Forms.Form parent, models.db.Row row, models.Context aContext)
        {
            bindedRow = row;
            context   = aContext;
            rowDirty  = false;
            Result result = Result.None;

            popup = new views.popup.DenpyouInfoPopup();
            popup.SetDatabase(context.KaikeiDatabase);
            popup.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
            popup.SetRowData(row);
            popup.Location = new System.Drawing.Point(
                Math.Max(parent.Left + (parent.Width - popup.Width) / 2, 0),
                Math.Max(parent.Top + (parent.Height - popup.Height) / 2, 0));

            popup.UpdateValue += UpdateValue;
            popup.FormClosing += delegate(object sender, FormClosingEventArgs args) {
                if (rowDirty)
                {
                    if (bindedRow.GetLong("id", -1) == -1)
                    {
                        bindedRow.Table.Insert(bindedRow);
                        result    = Result.Inserted;
                        bindedRow = bindedRow.Table.LastInsertedRow();
                    }
                    else
                    {
                        bindedRow.Table.Update(bindedRow);
                        result = Result.Updated;
                    }
                    (bindedRow.Table as models.db.tables.KaikeiDenpyouMeisai).UpdateMeisaiGroup(bindedRow, "");
                }
            };
            popup.RemoveButtonClicked += delegate() {
                if (bindedRow.GetLong("id", -1) == -1)
                {
                    helper.MsgBox.Err(KaikeiSystemBody.Properties.Resources.MsgFailedToRemoveRow);
                }
                else
                {
                    bindedRow.Table.Delete(bindedRow);
                    (bindedRow.Table as models.db.tables.KaikeiDenpyouMeisai).DeleteMeisaiGroup(bindedRow);
                    result = Result.Deleted;
                    popup.Close();
                }
            };

            popup.ShowDialog();
            popup.Dispose();

            return(result);
        }
Exemplo n.º 2
0
 public DenpyouInfoPopupController()
 {
     popup = null;
     delayTimerController = new misc.DelayTimerController(null);
 }