private void btnSaveClient_Click(object sender, EventArgs e)
        {
            //Create a new role that the Variable will be added into

            DataRow newClientRow = DM.dtClient.NewRow();

            // if any of the text area is empty then do not write the data and return error message
            if ((txtAddClientLastName.Text == "") || (txtAddClientFirstName.Text == "") || (txtAddClientStreetAddress.Text == "") ||
                (txtAddClientSuburb.Text == "") || (txtAddClientCity.Text == "") || (cboAddClientCountryID.Text == "") ||
                (cboAddClientCountryName.Text == "") || (txtAddClientEmail.Text == "") || (cboAddClientCreditStatus.Text == ""))
            {
                MessageBox.Show("You must type in all feilds", "Error");
            }

            else
            {
                newClientRow["LastName"]      = txtAddClientLastName.Text;
                newClientRow["FirstName"]     = txtAddClientFirstName.Text;
                newClientRow["StreetAddress"] = txtAddClientStreetAddress.Text;
                newClientRow["Suburb"]        = txtAddClientSuburb.Text;
                newClientRow["City"]          = txtAddClientCity.Text;
                newClientRow["CountryID"]     = cboAddClientCountryID.Text;
                newClientRow["Email"]         = txtAddClientEmail.Text;
                newClientRow["CreditStatus"]  = cboAddClientCreditStatus.Text;

                //Add the new row to the table
                DM.dtClient.Rows.Add(newClientRow);
                currencyManager.EndCurrentEdit();

                // Give the user the success message
                MessageBox.Show("Client added successfully", "Success");

                DM.UpdateClient();
            }
        }
        // This button click method combines a Challenge ID and a Competitor ID together to create a new record in
        // the Entry table, unless the competitor is already entered into that particular challenge.
        private void btnAddEntry_Click(object sender, EventArgs e)
        {
            try
            {
                if (DM.dtChallenge.Rows[cmChallenge.Position]["Status"].ToString() == "Scheduled")
                {
                    DataRow newEntry = DM.dtEntry.NewRow();

                    newEntry["ChallengeID"]  = dgvChallenge["ChallengeID", cmChallenge.Position].Value;
                    newEntry["CompetitorID"] = dgvCompetitor["CompetitorID", cmCompetitor.Position].Value;
                    newEntry["Status"]       = comChallengeEventStatus.Text;

                    DM.dsNZESL.Tables["Entry"].Rows.Add(newEntry);
                    currencyManager.EndCurrentEdit();
                    DM.UpdateEntry();

                    MessageBox.Show("Entry added successfully", "Success");
                }

                else
                {
                    MessageBox.Show("Competitors can only be entered to scheduled challenges", "Error");
                }
            }
            catch (ConstraintException)
            {
                MessageBox.Show("This competitor has already been entered in this challenge", "Error");
            }
        }
Пример #3
0
        //save the update
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            DataRow updateVacancyRow = DM.dtVacancy.Rows[currencyManager.Position];

            //stop the empty text to stop error
            if ((txtpnlUpDescription.Text == "") || (txtpnlUpSalary.Text == ""))
            {
                MessageBox.Show("You must enter a value for each text fields ");
                return;
            }
            else
            {
                //the salary should between 30000-200000
                if ((Convert.ToInt32(txtpnlUpSalary.Text) < 30000) || (Convert.ToInt32(txtpnlUpSalary.Text)) > 200000)

                {
                    MessageBox.Show("Salary should between 30000 and 200000");
                    return;
                }
                //update current row
                else
                {
                    updateVacancyRow["Description"] = txtpnlUpDescription.Text;
                    updateVacancyRow["Salary"]      = Convert.ToInt32(txtpnlUpSalary.Text);
                    currencyManager.EndCurrentEdit();
                    DM.UpdateVacancy();
                    MessageBox.Show("Vacancy updated successfully", "Success");
                }
            }
        }
        public void EndAddNew2()
        {
            BindingContext         bc   = new BindingContext();
            CancelAddNewList <int> list = new CancelAddNewList <int> ();

            list.Add(4);
            list.Add(6);

            CurrencyManager cm = (CurrencyManager)bc [list];

            Assert.AreEqual(false, list.EndNewCalled, "A1");
            Assert.AreEqual(false, list.CancelNewCalled, "A2");
            Assert.AreEqual(-1, list.LastIndex, "A3");

            cm.EndCurrentEdit();
            Assert.AreEqual(true, list.EndNewCalled, "B1");
            Assert.AreEqual(false, list.CancelNewCalled, "B2");
            Assert.AreEqual(0, list.LastIndex, "B3");

            cm.Position = 1;
            list.Reset();

            cm.EndCurrentEdit();
            Assert.AreEqual(true, list.EndNewCalled, "C1");
            Assert.AreEqual(false, list.CancelNewCalled, "C2");
            Assert.AreEqual(1, list.LastIndex, "C3");
        }
        private void btnSaveBook_Click(object sender, EventArgs e)
        {
            //Create a new role that the Variable will be added into
            DataRow newBookrow = DM.dtBook.NewRow();

            // if any of the text area is empty then do not write the data and return error message
            if ((cboAddBookInfoID.Text == "") || (txtAddBookInfoCost.Text == "") || (txtAddBookInfoPrice.Text == "") ||
                (dtpAddBookPublished.Text == "") || (cboAddBookVendorID.Text == ""))
            {
                MessageBox.Show("You must type in all feilds", "Error");
            }

            else
            {
                newBookrow["BookInfoID"]    = cboAddBookInfoID.Text;
                newBookrow["Cost"]          = txtAddBookInfoCost.Text;
                newBookrow["Price"]         = txtAddBookInfoPrice.Text;
                newBookrow["DatePublished"] = dtpAddBookPublished.Text;
                newBookrow["VendorID"]      = cboAddBookVendorID.Text;

                //Add the new row to the table
                DM.dtBook.Rows.Add(newBookrow);
                currencyManager.EndCurrentEdit();

                // Give the user the success message
                MessageBox.Show("Book added successfully", "Success");

                DM.UpdateBook();
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //Create a new row that the variables will be added into
            DataRow newServiceRow = DM.dtService.NewRow();

            //If any of the text areas are empty then do not write data and return
            if ((cboAddVehicleID.Text == "") || (cboAddServiceType.Text == "") ||
                (txtAddHours.Text == "") || (dtpServiceDate.Text == ""))
            {
                MessageBox.Show("You must enter a value for each of the text fields.", "Error");
            }
            else
            {
                //newServiceRow["VehicleID"] = cboVehicleID.Text;
                //newServiceRow["ServiceTypeID"] = cboServiceType.Text;
                newServiceRow["Hours"]       = txtAddHours.Text;
                newServiceRow["ServiceDate"] = dtpServiceDate.Text;
                //newServiceRow["Status"] = txtStatus.Text == "Pending";

                //Add the new row to the Table
                cmService.EndCurrentEdit();
                DM.UpdateService();
                //Give the user a success message
                MessageBox.Show("Service updated successfully.", "Success");
            }
            return;
        }
Пример #7
0
        private void btnSaveClientOrder_Click(object sender, EventArgs e)
        {

            //Create a new role that the Variable will be added into
            DataRow newClientOrderRow = DM.dtClientOrder.NewRow();

            // if any of the text area is empty then do not write the data and return error message
            if (dtpAddClientOrder.Text == "")
            {
                MessageBox.Show("You must enter a Order Date and Client ID", "Error");
            }

            else
            {
                newClientOrderRow["OrderDate"] = dtpAddClientOrder.Text;
                newClientOrderRow["ClientID"] = cboAddClientID.Text;
                newClientOrderRow["Status"] = "Current";

                //Add the new row to the table
                DM.dtClientOrder.Rows.Add(newClientOrderRow);
                currencyManager.EndCurrentEdit();
                DM.UpdateClientOrder();
                // Give the user the success message
                MessageBox.Show("Client Order Added Successfully");
            }
        }
Пример #8
0
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            DataRow updateBugRow = DM.dtBug.Rows[currencyManager.Position];

            if ((txtUpdateComment.Text == ""))
            {
                MessageBox.Show("You must type in a comment.", "Error");
            }
            else
            {
                updateBugRow["Status"]     = cboUpdateStatus.Text;
                updateBugRow["ActualDate"] = dtpUpdateActualD.Text;
                updateBugRow["EmployeeID"] = cboUpdateEmployeeID.Text;
                updateBugRow["Comment"]    = txtUpdateComment.Text;
                updateBugRow["Assigned"]   = "Assigned";
                currencyManager.EndCurrentEdit();
                DM.UpdateBug();
                MessageBox.Show("Bug record updated successfully.", "Success");
                pnlUpdateBug.Hide();
                lstBug.Visible       = true;
                btnReturn.Enabled    = true;
                btnDeleteBug.Enabled = true;
                btnNext.Enabled      = true;
                btnPrevious.Enabled  = true;
                btnAddBug.Enabled    = true;
            }
        }
Пример #9
0
 /// <summary>
 /// add book to client order
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAddBook_Click(object sender, EventArgs e)
 {
     try
     {
         if (DM.dtClientOrder.Rows[cmClientOrder.Position]["Status"].ToString() == "Current")
         {
             string clientOrderID  = DM.dtClientOrder.Rows[cmClientOrder.Position]["ClientOrderID"].ToString();
             int    aClientOrderID = Convert.ToInt32(clientOrderID);
             string bookID         = dgvUnorderedBooks["BookID", cmUnorderedBooks.Position].Value.ToString();
             int    aBookID        = Convert.ToInt32(bookID);
             cmBook.Position = DM.bookView.Find(aBookID);
             DataRow newOrder = DM.dtBook.Rows[cmBook.Position];
             newOrder["ClientOrderID"] = aClientOrderID;
             cmBook.EndCurrentEdit();
             DM.UpdateBook();
             UpdateOrderedBooks();
             UpdateUnorderedBooks();
             MessageBox.Show("Book Added to Client Order Successfully!", "Success");
         }
         else
         {
             MessageBox.Show("Books can only be added to current orders!", "Error");
         }
     }
     catch (ConstraintException)
     {
         MessageBox.Show("This book has already been added to this client order!", "Error");
     }
 }
Пример #10
0
 private void button1_Click(object sender, EventArgs e)
 {
     cm.EndCurrentEdit();
     commandbuilder = new SqlCommandBuilder(da);
     da.Update(datatable);
     MessageBox.Show("ADDED ", "Addtion");
     label4.Text = (cm.Position + 1) + " / " + datatable.Rows.Count;
 }
Пример #11
0
        /// <summary>
        /// update a client order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            DataRow updateClientOrderRow = DM.dtClientOrder.Rows[currencyManager.Position];

            updateClientOrderRow["OrderDate"] = this.dtpUpdateOrderDate.Text;
            currencyManager.EndCurrentEdit();
            DM.UpdateClientOrder();
            MessageBox.Show("Client Order Updated Successfully!", "Success");
        }
Пример #12
0
        //Update Book Info in the table
        private void btnUpdSave_Click(object sender, EventArgs e)
        {
            DataRow updClientOrderRow = DM.dtClientOrder.Rows[currencyManager.Position];

            updClientOrderRow["OrderDate"] = dtpUpdClientOrderDate.Text;
            currencyManager.EndCurrentEdit();
            MessageBox.Show("Client Order was updated successfully", "Success");
            DM.UpdateClientOrder();
        }
Пример #13
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     // زر الاضافة
     cm.EndCurrentEdit();
     cmdb = new SqlCommandBuilder(adapter);
     adapter.Update(Dt);
     cm.Refresh();
     MessageBox.Show("Add Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Пример #14
0
        //Function to save the modified Race record
        private void btnSaveUpdateRace_Click(object sender, EventArgs e)
        {
            DataRow updateRaceRow = DM.dtRace.Rows[currencyManager.Position];

            if (txtUpdateRaceName.Text == "")
            {
                MessageBox.Show("Race Name must not be empty!", "Error");
            }
            else if (txtUpdateRaceName.Text.Length > 30)
            {
                MessageBox.Show("Race Name must not exceed 30 characters!", "Error");
            }
            else if (txtUpdateRaceTime.Text == "")
            {
                MessageBox.Show("Race Time must not be empty!", "Error");
            }
            else if (npUpdateRaceCapacity.Text == "")
            {
                MessageBox.Show("Race Capacity must not be empty!", "Error");
            }
            else if (Convert.ToInt32(npUpdateRaceCapacity.Text) <= 1 || Convert.ToInt32(npUpdateRaceCapacity.Text) >= 40)
            {
                MessageBox.Show("Race Capacity must be between 2 and 39!", "Error");
            }
            else
            {
                try
                {
                    //Add the modified record to the existing record
                    updateRaceRow["RaceName"] = txtUpdateRaceName.Text;
                    updateRaceRow["RaceTime"] = txtUpdateRaceTime.Text;
                    updateRaceRow["Capacity"] = npUpdateRaceCapacity.Text;

                    currencyManager.EndCurrentEdit();
                    DM.UpdateRace(); //Update database
                    MessageBox.Show("Race updated successfully.", "Success");

                    //Close Update Race Course Panel and Reset the buttons to its normal state
                    pnlUpdateRace.Hide();
                    lstRaces.Enabled              = true;
                    lstRaces.Visible              = true;
                    btnPrevious.Enabled           = true;
                    btnNext.Enabled               = true;
                    btnAddRace.Enabled            = true;
                    btnDeleteRace.Enabled         = true;
                    btnMarkRaceAsFinished.Enabled = true;
                    btnMarkRaceAsComplete.Enabled = true;
                    btnReturn.Enabled             = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Please use a time format for Race Time. Ex: 7:00 or 13:00", "Error");
                }
            }
        }
Пример #15
0
        // This is a button click method that validates and saves the new Event details, entered into the Add Event
        // panel, into the database. If the data is invalid, it gives an error message. It then hides the Add Event
        // panel, and shows the previously hidden text boxes, labels and the list box, and re-enables the buttons.
        private void btnSaveMeeting_Click(object sender, EventArgs e)
        {
            DataRow newEventRow = DM.dtEvent.NewRow();

            if ((txtAddEventName.Text == "") || (comAddEventArenaID.Text == "") || (comAddEventStatus.Text == "") ||
                (datAddEventDate.Text == ""))
            {
                MessageBox.Show("Please fill in all fields", "Error");
            }
            else if (numAddEventCapacity.Value < 100)
            {
                MessageBox.Show("The minimum capacity for an event is 100 people.", "Error");
            }
            else
            {
                newEventRow["EventName"] = txtAddEventName.Text;
                newEventRow["ArenaID"]   = comAddEventArenaID.Text;
                newEventRow["Status"]    = comAddEventStatus.Text;
                newEventRow["Capacity"]  = numAddEventCapacity.Text;
                newEventRow["EventDate"] = datAddEventDate.Text;
                DM.dtEvent.Rows.Add(newEventRow);
                DM.UpdateEvent();
                currencyManager.EndCurrentEdit();
                MessageBox.Show("Event added successfully", "Success");
                lstEventName.Show();
                lblEventID.Show();
                lblEventName.Show();
                lblEventArenaID.Show();
                lblEventArenaName.Show();
                lblEventStatus.Show();
                lblEventCapacity.Show();
                lblEventDate.Show();
                txtEventID.Show();
                txtEventName.Show();
                txtEventArenaID.Show();
                txtEventArenaName.Show();
                txtEventStatus.Show();
                txtEventCapacity.Show();
                datEventDate.Show();
                btnPrevious.Enabled    = true;
                btnNext.Enabled        = true;
                btnUpdateEvent.Enabled = true;
                btnDeleteEvent.Enabled = true;
                btnReturn.Enabled      = true;
                pnlAddEvent.Hide();
                txtAddEventName.Text    = "";
                comAddEventArenaID.Text = "";
                comAddEventStatus.Text  = "";
            }
        }
Пример #16
0
        // This is a button click method that validates and saves the new challenge details, entered into the Add
        // Challenge panel, into the database. If the data is invalid, it gives an error message. It then hides the Add
        // Challenge panel, and shows the previously hidden text boxes, labels and the list box, and re-enables the
        // buttons. Finally, it removes the information from the Add Challenge panel's text fields so that if the user
        // wishes to add another new challenge, they won't need to erase the previous data from the text fields.
        private void btnSaveAddChallenge_Click(object sender, EventArgs e)
        {
            DataRow newChallengeRow = DM.dtChallenge.NewRow();

            {
                if ((txtAddChallengeName.Text == "") || (comAddEventID.Text == "") || (comAddEventName.Text == "") ||
                    (datAddStartTime.Text == "") || (comAddEventStatus.Text == "") || (numAddCapacity.Value == 0))
                {
                    MessageBox.Show("Please fill in all fields", "Error");
                }
                else
                {
                    newChallengeRow["ChallengeName"] = txtAddChallengeName.Text;
                    newChallengeRow["StartTime"]     = datAddStartTime.Text;
                    newChallengeRow["EventID"]       = comAddEventID.Text;
                    newChallengeRow["Status"]        = comAddEventStatus.Text;
                    newChallengeRow["Capacity"]      = Convert.ToInt32(numAddCapacity.Value);
                    DM.dtChallenge.Rows.Add(newChallengeRow);
                    DM.UpdateChallenge();
                    currencyManager.EndCurrentEdit();
                    MessageBox.Show("Challenge added successfully", "Success");
                    lstChallengeID.Show();
                    lblChallengeID.Show();
                    lblChallengeName.Show();
                    lblEventID.Show();
                    lblEventName.Show();
                    lblStartTime.Show();
                    lblStatus.Show();
                    lblCapacity.Show();
                    txtChallengeID.Show();
                    txtChallengeName.Show();
                    txtEventID.Show();
                    txtEventName.Show();
                    datStartTime.Show();
                    txtStatus.Show();
                    txtCapacity.Show();
                    btnPrevious.Enabled          = true;
                    btnNext.Enabled              = true;
                    btnUpdateChallenge.Enabled   = true;
                    btnDeleteChallenge.Enabled   = true;
                    btnChallengeFinished.Enabled = true;
                    btnChallengeComplete.Enabled = true;
                    btnReturn.Enabled            = true;
                    pnlAddChallenge.Hide();
                    txtAddChallengeName.Text = "";
                    numAddCapacity.Value     = 1;
                }
            }
        }
Пример #17
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtCatName.Text))
     {
         cm.EndCurrentEdit(); // the new category is added to the source dt // if we comment that line the add will not be performed
         BL.Category.AUDCategory(dt);
         MessageBox.Show("The Product is Added Successfully", "Product", MessageBoxButtons.OK, MessageBoxIcon.Information);
         btnNew.Enabled = true; btnAdd.Enabled = false; btnCancel.Enabled = false;
         btnDel.Enabled = true; btnModify.Enabled = true;
     }
     else
     {
         MessageBox.Show("You Should enter valid values", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        private void btnSaveBookInfo_Click(object sender, EventArgs e)
        {
            //Create a new role that the Variable will be added into
            DataRow newBookInforow = DM.dtBookInfo.NewRow();

            newBookInforow["Title"]    = txtAddBookTitle.Text;
            newBookInforow["AuthorID"] = cboAddBookAuthorID.Text;
            newBookInforow["Notes"]    = txtAddAuthorNotes.Text;
            DM.dtBookInfo.Rows.Add(newBookInforow);
            currencyManager.EndCurrentEdit();
            // Give the user the success message
            MessageBox.Show("Book Info added successfully", "Success");
            // Database is updated
            DM.UpdateBookInfo();
        }
        // This is a button click method that validates and saves the new competitor details, entered into the Add
        // Competitor panel, into the database. If the data is invalid, it gives an error message. It then hides the
        // Add Competitor panel, and shows the previously hidden text boxes, labels and the list box, and re-enables the
        // buttons. Finally, it removes the information from the Add Competitor panel's text fields so that if the user
        // wishes to add another new competitor, they won't need to erase the previous data from the text fields.
        private void btnSaveAddCompetitor_Click(object sender, EventArgs e)
        {
            DataRow newCompetitorRow = DM.dtCompetitor.NewRow();

            if ((txtAddUserName.Text == "") || (txtAddFirstName.Text == "") || (txtAddLastName.Text == "") ||
                (txtAddEmail.Text == ""))
            {
                MessageBox.Show("Please fill in all fields", "Error");
            }
            else
            {
                newCompetitorRow["UserName"]     = txtAddUserName.Text;
                newCompetitorRow["FirstName"]    = txtAddFirstName.Text;
                newCompetitorRow["LastName"]     = txtAddLastName.Text;
                newCompetitorRow["Gender"]       = comAddGender.Text;
                newCompetitorRow["DateOfBirth"]  = datAddDateOfBirth.Text;
                newCompetitorRow["EmailAddress"] = txtAddEmail.Text;
                DM.dtCompetitor.Rows.Add(newCompetitorRow);
                DM.UpdateCompetitor();
                currencyManager.EndCurrentEdit();
                MessageBox.Show("Competitor added successfully", "Success");
                lstUserName.Show();
                lblCompetitorID.Show();
                lblUserName.Show();
                lblFirstName.Show();
                lblLastName.Show();
                lblGender.Show();
                lblDateOfBirth.Show();
                lblEmail.Show();
                txtCompetitorID.Show();
                txtUserName.Show();
                txtFirstName.Show();
                txtLastName.Show();
                txtGender.Show();
                datDateOfBirth.Show();
                txtEmail.Show();
                btnPrevious.Enabled         = true;
                btnNext.Enabled             = true;
                btnUpdateCompetitor.Enabled = true;
                btnDeleteCompetitor.Enabled = true;
                btnReturn.Enabled           = true;
                pnlAddCompetitor.Hide();
                txtAddUserName.Text  = "";
                txtAddFirstName.Text = "";
                txtAddLastName.Text  = "";
                txtAddEmail.Text     = "";
            }
        }
Пример #20
0
        private void btnGuncelle_Click(object sender, EventArgs e)
        {
            CurrencyManager sonraki = (CurrencyManager)this.BindingContext[al.Tables["SATICI"]];

            sonraki.EndCurrentEdit();
            cb = new OleDbCommandBuilder(verial); // OleDbDataAdapter'i silme, güncelleme ve kayıt'a hazır hale getirmek için
            verial.Update(al, "SATICI");
            al.Clear();
            verial.Fill(al.Tables[0]);

            grdSatici.DataSource = al.Tables[0];
            MessageBox.Show(" Güncelleme tamamlandı!", "İŞLEM TAMAM");

            // Temizle
            txtFirmaAdi.Clear();
            txtYetkili.Clear();
            txtAdres.Clear();
            mskIsTel.Clear();
            mskCepTel.Clear();

            txtFirmaAdi.Enabled = false;
            txtYetkili.Enabled  = false;
            txtAdres.Enabled    = false;
            mskIsTel.Enabled    = false;
            mskCepTel.Enabled   = false;
        }
Пример #21
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.ListView.AfterLabelEdit" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.LabelEditEventArgs" /> that contains the event data.</param>
#else
        /// <summary>
        /// Raises the <see cref="E:Gizmox.WebGUI.Forms.ListView.AfterLabelEdit"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:Gizmox.WebGUI.Forms.LabelEditEventArgs"></see> that contains the event data.</param>
#endif
        protected override void OnAfterLabelEdit(LabelEditEventArgs e)
        {
            if (e.Label == null)
            {
                // If you press ESC while editing.
                e.CancelEdit = true;
                return;
            }

            if (_listManager.List.Count > e.Item)
            {
                var row = _listManager.List[e.Item];
                // In a ListView you are only able to edit the first Column.
                var col = _listManager.GetItemProperties().Find(Columns[0].Text, false);
                try
                {
                    if (row != null && col != null)
                    {
                        col.SetValue(row, e.Label);
                    }
                    _listManager.EndCurrentEdit();
                    base.OnAfterLabelEdit(e);
                }
                catch (Exception ex)
                {
                    // If you try to enter strings in number-columns, too long strings or something
                    // else wich is not allowed by the DataSource.
                    MessageBox.Show(Resources.EditFailed + ": " + ex.Message, Resources.EditFailed, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _listManager.CancelCurrentEdit();
                    e.CancelEdit = true;
                }
            }
        }
Пример #22
0
        /// <summary>
        /// Check if fields are blank
        /// If not blank, update candidate rows in the database
        /// Catch error
        /// </summary>
        private void btnUpdateSaveChanges_Click(object sender, EventArgs e)
        {
            DataRow updateCandidateRow = DM.dtCandidate.Rows[currencyManager.Position];

            if ((txtUpdateFirstName.Text == "") || (txtUpdateLastName.Text == "") || (txtUpdateStreetAddress.Text == "") || (txtUpdateSuburb.Text == "") || (txtUpdatePhoneNumber.Text == ""))
            {
                MessageBox.Show("You must ype in an candidate name, phone number, street address and suburb");
            }
            else
            {
                try
                {
                    updateCandidateRow["LastName"]      = txtUpdateLastName.Text;
                    updateCandidateRow["FirstName"]     = txtUpdateFirstName.Text;
                    updateCandidateRow["StreetAddress"] = txtUpdateStreetAddress.Text;
                    updateCandidateRow["Suburb"]        = txtUpdateSuburb.Text;
                    updateCandidateRow["PhoneNumber"]   = txtUpdatePhoneNumber.Text;
                    currencyManager.EndCurrentEdit();
                    DM.UpdateCandidate();
                    MessageBox.Show("Candidate updated Successfully", "Success");
                }
                catch
                {
                    MessageBox.Show("Please Enter The Proper type for each fields");
                }
            }
        }
        //Método que busca todos os clientes na API
        public async void GetAllUsers()
        {
            using (var client = new HttpClient())
            {
                //Corrige erro de autenticação
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
                //

                using (var response = await client.GetAsync("https://localhost:5001/api/user/"))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        var UsersJsonString = await response.Content.ReadAsStringAsync();

                        gridFunc.DataSource = 0;
                        gridFunc.Columns.Clear();
                        gridFunc.Refresh();

                        gridFunc.DataSource = JsonConvert.DeserializeObject <ContaClientes[]>(UsersJsonString).ToList();
                        gridFunc.Update();
                        gridFunc.Refresh();

                        //Criao o botão delete
                        DataGridViewButtonColumn uninstallButtonColumn = new DataGridViewButtonColumn();
                        uninstallButtonColumn.UseColumnTextForButtonValue = true;
                        uninstallButtonColumn.HeaderText = "Delete";
                        uninstallButtonColumn.Name       = "Delete";
                        uninstallButtonColumn.Text       = "Delete";
                        gridFunc.Columns.Insert(6, uninstallButtonColumn);

                        // Oculta colunas desnecessárias do sistema
                        for (int i = 7; i < 60; i++)
                        {
                            gridFunc.Columns[i].Visible = false;
                        }

                        // Oculta usuários Clientes
                        foreach (DataGridViewRow row in gridFunc.Rows)
                        {
                            //permite ocultar linhas protegidas
                            CurrencyManager cm = (CurrencyManager)BindingContext[gridFunc.DataSource];
                            cm.EndCurrentEdit();
                            cm.ResumeBinding();
                            cm.SuspendBinding();

                            DataGridViewCheckBoxCell ck = (DataGridViewCheckBoxCell)row.Cells[5];
                            //Passa se o checkBox estiver selecionado;
                            if (Convert.ToBoolean(ck.Value) == false)
                            {
                                row.Visible = false;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Não foi possível obter usuários : " + response.StatusCode);
                    }
                }
            }
        }
Пример #24
0
        private void updateKaiBtn_Click(object sender, EventArgs e)
        {
            var currentKaiRow   = _dataModule.KaiTable.Rows[_kaiCurrencyManager.Position];
            var currentEventRow = _dataModule.EventTable.Rows[_eventCurrencyManager.Position];

            if (addPanelEventName.Text == "" || addFormKaiName.Text == "" || addPanelServingQuantity.Text == "" || addPanelPreparationTime.Text == "")
            {
                MessageBox.Show("You must enter a value for each of the text fields", "ERROR OCCURED");
                return;
            }


            currentEventRow["EventName"] = addPanelEventName.Text;
            _eventCurrencyManager.EndCurrentEdit();
            _dataModule.UpdateEventTable();


            currentKaiRow["EventId"]             = currentEventRow["EventId"];
            currentKaiRow["KaiName"]             = addFormKaiName.Text;
            currentKaiRow["ServeQuantity"]       = Int32.Parse(addPanelServingQuantity.Text.ToString());
            currentKaiRow["PreparationMinutes"]  = Int32.Parse(addPanelPreparationTime.Text.ToString());
            currentKaiRow["PreparationRequired"] = kaiAddCheckBox.Checked;

            _kaiCurrencyManager.EndCurrentEdit();
            _dataModule.UpdateKaiTable();

            MessageBox.Show("Kai updated successfully", "Action succeed!");
            addKaiCancelBtn_Click(sender, e);
        }
Пример #25
0
        private void panelUpdateWhanauBtn_Click(object sender, EventArgs e)
        {
            if (
                string.IsNullOrEmpty(panelAddFirstName.Text) ||
                string.IsNullOrEmpty(panelAddLastName.Text) ||
                string.IsNullOrEmpty(panelAddEmail.Text) ||
                string.IsNullOrEmpty(panelAddPhone.Text) ||
                string.IsNullOrEmpty(panelAddAddress.Text))
            {
                MessageBox.Show("Please complete auto fields before save", "Idiot control !!!!!!!!!");
                return;
            }
            bool isEmail = Regex.IsMatch(panelAddEmail.Text, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

            if (!isEmail)
            {
                MessageBox.Show("Email address is not valid", "Idiot control !!!!!!!!!");
                return;
            }
            var whanauRecord = _dataModule.WhanauTable.Rows[_whanauCurrencyManager.Position];

            whanauRecord["FirstName"] = panelAddFirstName.Text;
            whanauRecord["LastName"]  = panelAddLastName.Text;
            whanauRecord["Email"]     = panelAddEmail.Text;
            whanauRecord["Phone"]     = panelAddPhone.Text;
            whanauRecord["Address"]   = panelAddAddress.Text;

            _whanauCurrencyManager.EndCurrentEdit();
            _dataModule.UpdateWhanauTable();

            MessageBox.Show("Whānau updated successfully", "Succeed");
            panelCancel_Click(sender, e);
        }
Пример #26
0
        //Update Client in the table
        private void btnUpdSave_Click(object sender, EventArgs e)
        {
            DataRow updClientRow = DM.dtClient.Rows[currencyManager.Position];

            if (txtUpdLastName.Text == "")
            {
                MessageBox.Show("You must type in a Client's Last Name", "Error");
            }

            else if (txtUpdFirstName.Text == "")
            {
                MessageBox.Show("You must type in a Client's First Name", "Error");
            }

            else if (txtUpdStreetAddress.Text == "")
            {
                MessageBox.Show("You must type in a Client's Street Address", "Error");
            }

            else if (txtUpdSuburb.Text == "")
            {
                MessageBox.Show("You must type in a Client's Suburb Name", "Error");
            }

            else if (txtUpdCity.Text == "")
            {
                MessageBox.Show("You must type in a Client's City Name", "Error");
            }

            else if (isValidEmail(txtUpdEmail.Text) == false)
            {
                MessageBox.Show("You must type an Email in correct format", "Error");
            }

            else if (isLetterContains(txtUpdLastName.Text) == false)
            {
                MessageBox.Show("Client's Last Name can contain only letters", "Error");
            }

            else if (isLetterContains(txtUpdFirstName.Text) == false)
            {
                MessageBox.Show("Client's First Name can contain only letters", "Error");
            }

            else
            {
                updClientRow["City"]          = txtUpdCity.Text;
                updClientRow["Email"]         = txtUpdEmail.Text;
                updClientRow["FirstName"]     = txtUpdFirstName.Text;
                updClientRow["LastName"]      = txtUpdLastName.Text;
                updClientRow["StreetAddress"] = txtUpdStreetAddress.Text;
                updClientRow["Suburb"]        = txtUpdSuburb.Text;
                updClientRow["CreditStatus"]  = cboUpdCreditStatus.Text;
                updClientRow["CountryID"]     = cboUpdCountryID.Text;

                currencyManager.EndCurrentEdit();
                MessageBox.Show("Client was updated successfully", "Success");
                DM.UpdateClient();
            }
        }
        private void btnSaveChanges2_Click(object sender, EventArgs e)
        {
            DataRow updateMeetingRow = DM.dtMeeting.Rows[currencyManager.Position];

            if ((txtMeetingName2.Text == "") || (numCapacity2.Value.ToString() == ""))
            {
                MessageBox.Show("You must enter a value for each of the text fields", "Error");
            }
            else if (int.Parse(numCapacity2.Value.ToString()) <= 1000 || int.Parse(numCapacity2.Value.ToString()) >= 20000)
            {
                MessageBox.Show("You must enter a value for capacity more than 1000 and less than 20000", "Error");
            }
            else
            {
                updateMeetingRow["MeetingName"] = txtMeetingName2.Text;
                updateMeetingRow["Status"]      = cmbStatus2.Text;
                updateMeetingRow["Capacity"]    = int.Parse(numCapacity2.Value.ToString());
                updateMeetingRow["MeetingDate"] = dtpMeetingDate2.Value.ToString();
                currencyManager.EndCurrentEdit();
                DM.UpdateMeeting();
                MessageBox.Show("Meeting updated successfully", "Success");

                pnlUpdateMeeting.Visible = false;
                lstMeeting.Visible       = true;
                btnPrevious.Enabled      = true;
                btnNext.Enabled          = true;
                btnAddMeeting.Enabled    = true;
                btnDeleteMeeting.Enabled = true;
                btnReturn.Enabled        = true;
            }
        }
Пример #28
0
        private void carregaGrid()
        {
            dgvExclui.AutoGenerateColumns = false;
            try
            {
                List <usuarioDTO> ListDto = new List <usuarioDTO>();
                ListDto = new usuarioBLL().listaUsuario();
                dgvExclui.DataSource = ListDto;
                CurrencyManager cm = (CurrencyManager)BindingContext[dgvExclui.DataSource];
                cm.EndCurrentEdit();
                cm.ResumeBinding();
                cm.SuspendBinding();

                foreach (DataGridViewRow row in dgvExclui.Rows)
                {
                    if (Convert.ToInt32(row.Cells["tipo"].Value) == 1)
                    {
                        row.Cells["teste"].Value = Convert.ToString("Professor");
                    }
                    else if (Convert.ToInt32(row.Cells["tipo"].Value) == 2)
                    {
                        row.Cells["teste"].Value = Convert.ToString("Técnico");
                    }

                    else
                    {
                        row.Visible = false;
                    }
                }
            }
            catch (Exception erro)
            {
                throw erro;
            }
        }
Пример #29
0
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            DataRow updateTestRow = DM.dtTest.Rows[currencyManager.Position];

            if ((txtUpdateComment.Text == ""))
            {
                MessageBox.Show("You must type in a comment.", "Error");
            }
            else
            {
                updateTestRow["Status"]  = cboUpdateStatus.Text;
                updateTestRow["DateEnd"] = dtpDEnd.Text;
                updateTestRow["Comment"] = txtUpdateComment.Text;
                currencyManager.EndCurrentEdit();
                DM.UpdateTest();
                MessageBox.Show("Test updated successfully.", "Success");
                pnlUpdateTest.Hide();
                lstTest.Visible       = true;
                btnReturn.Enabled     = true;
                btnDeleteTest.Enabled = true;
                btnNext.Enabled       = true;
                btnPrevious.Enabled   = true;
                btnAddTest.Enabled    = true;
            }
        }
Пример #30
0
        private void btnUpdateVehicle_Click(object sender, EventArgs e)
        {
            DataRow updateVehicleRow = DM.dtVehicle.Rows[currencyManager.Position];

            if ((txtAddPlateNumber.Text == "") || (txtAddMake.Text == "") ||
                (txtAddModel.Text == ""))
            {
                MessageBox.Show("You must enter a value for each of the text fields.", "Error");
                return;
            }
            else
            {
                //Update the text areas
                updateVehicleRow["PlateNumber"] = txtAddPlateNumber.Text;
                updateVehicleRow["Make"]        = txtAddMake.Text;
                updateVehicleRow["Model"]       = txtAddModel.Text;
                //updateVehicleRow["OwnerID"] = cboAddOwner.Text;

                //Update the database
                currencyManager.EndCurrentEdit();
                DM.UpdateVehicle();

                //Give the user a success message
                MessageBox.Show("Vehicle updated successfully.", "Success");
            }
            return;
        }