void gnc_employee_window_ok_cb (GtkWidget *widget, gpointer data) { EmployeeWindow *ew = data; gchar *string; /* Check for valid username */ if (check_entry_nonempty (ew->dialog, ew->username_entry, _("You must enter a username."))) return; /* Check for valid username */ if (check_entry_nonempty (ew->dialog, ew->name_entry, _("You must enter the employee's name."))) return; /* Make sure we have an address */ if (check_entry_nonempty (ew->dialog, ew->addr1_entry, NULL) && check_entry_nonempty (ew->dialog, ew->addr2_entry, NULL) && check_entry_nonempty (ew->dialog, ew->addr3_entry, NULL) && check_entry_nonempty (ew->dialog, ew->addr4_entry, NULL)) { const char *msg = _("You must enter an address."); gnc_error_dialog (ew->dialog, "%s", msg); return; } /* Set the employee id if one has not been chosen */ if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (ew->id_entry)), "") == 0) { string = gncEmployeeNextID (ew->book); gtk_entry_set_text (GTK_ENTRY (ew->id_entry), string); g_free(string); } /* Now save it off */ { GncEmployee *employee = ew_get_employee (ew); if (employee) { gnc_ui_to_employee (ew, employee); } ew->created_employee = employee; ew->employee_guid = *guid_null (); } gnc_close_gui_component (ew->component_id); }
void gnc_customer_window_ok_cb (GtkWidget *widget, gpointer data) { CustomerWindow *cw = data; gnc_numeric min, max; gchar *string; /* Check for valid company name */ if (check_entry_nonempty (cw->dialog, cw->company_entry, _("You must enter a company name. " "If this customer is an individual (and not a company) " "you should enter the same value for:\nIdentification " "- Company Name, and\nPayment Address - Name."))) return; /* Make sure we have an address */ if (check_entry_nonempty (cw->dialog, cw->addr1_entry, NULL) && check_entry_nonempty (cw->dialog, cw->addr2_entry, NULL) && check_entry_nonempty (cw->dialog, cw->addr3_entry, NULL) && check_entry_nonempty (cw->dialog, cw->addr4_entry, NULL)) { const char *msg = _("You must enter a billing address."); gnc_error_dialog (cw->dialog, "%s", msg); return; } /* Verify terms, discount, and credit are valid (or empty) */ min = gnc_numeric_zero (); max = gnc_numeric_create (100, 1); if (check_edit_amount (cw->dialog, cw->discount_amount, &min, &max, _("Discount percentage must be between 0-100 " "or you must leave it blank."))) return; if (check_edit_amount (cw->dialog, cw->credit_amount, &min, NULL, _("Credit must be a positive amount or " "you must leave it blank."))) return; /* Set the customer id if one has not been chosen */ if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (cw->id_entry)), "") == 0) { string = gncCustomerNextID (cw->book); gtk_entry_set_text (GTK_ENTRY (cw->id_entry), string); g_free(string); } /* Now save it off */ { GncCustomer *customer = cw_get_customer (cw); if (customer) { gnc_ui_to_customer (cw, customer); } cw->created_customer = customer; cw->customer_guid = *guid_null (); } gnc_close_gui_component (cw->component_id); }