Example #1
0
        //
        // EDITED EVENT HANDLERS
        //
        private void CustID_Edited(object o, Gtk.EditedArgs args)
        {
            // Set and Get data
            Gtk.TreeIter iter;
            Gtk.TreePath treepath = new Gtk.TreePath (args.Path);
            Gtk.CellRendererText nextCell = (Gtk.CellRendererText)checktableview.columnList [(int)ColumnType.CHECK_NUMBER].Cell;
            Gtk.TreeViewColumn nextColumn = checktableview.columnList [(int)ColumnType.CHECK_NUMBER].Column;
            string text = BL.Formatter.GetNumericID (args.NewText);

            // Get iter
            checkPropsList.GetIter (out iter, treepath);
            // Get Check
            BL.CheckClass check = (BL.CheckClass)checkPropsList.GetValue (iter, 0);

            // Find customer
            BL.Customer customer = DAL.DataManager.GetCustomer (text);

            if (customer != null) {
                check.CustomerID = customer.Identity;
                checkPropsList.SetValue (iter, 1, customer.Name);

                // Move to next cell
                checktableview.SetCursorOnCell (treepath, nextColumn, nextCell, true);

            } else if (!text.Equals ("")) {
                Gtk.MessageDialog dialog = YesNoDialog ("Cliente não existente!\nQuer adicioná-lo?");
                Gtk.ResponseType result = (Gtk.ResponseType)dialog.Run ();
                if (result == Gtk.ResponseType.Yes) {
                    dialog.Destroy ();
                    Dialogs.AddCustomerDialog addCustDia = new Dialogs.AddCustomerDialog ();
                    addCustDia.AddedCustomer += (object sender, Cheque.GTK.Dialogs.AddCustomerEventArgs e) => {
                        check.CustomerID = BL.Formatter.GetNumericID (e.CustomerID);
                    };
                    addCustDia.GetEntryID ().Text = text;
                    addCustDia.Run ();
                    customer = DAL.DataManager.GetCustomer (check.CustomerID);
                    if (customer != null) {
                        checkPropsList.SetValue (iter, 1, customer.Name);
                        checktableview.SetCursorOnCell (treepath, nextColumn, nextCell, true);
                    }
                }
                dialog.Destroy ();
            }
        }
Example #2
0
        private void AddCustomer()
        {
            MessageDialog md = new MessageDialog (null,
                                                  DialogFlags.DestroyWithParent,
                                                  MessageType.Question,
                                                  ButtonsType.YesNo, "Cliente não existe! Quer adicioná-lo?");

            ResponseType result = (ResponseType)md.Run ();

            if (result == ResponseType.Yes) {
                md.Destroy ();
                Dialogs.AddCustomerDialog addCustDia = new Dialogs.AddCustomerDialog ();
                addCustDia.GetEntryID ().Text = Formatter.GetNumericID (entryID.Text);
                ResponseType ans = (ResponseType)addCustDia.Run ();

                // If answer was OK, add customer
                if (ans == ResponseType.Ok) {
                    Customer customer = DAL.DataManager.GetCustomer (Formatter.GetNumericID (entryID.Text));
                    if (customer != null) {
                        check.CustomerID = customer.Identity;
                        SetCustomerName (customer.Name);
                    }
                }
            } else {
                md.Destroy ();
            }
        }