private void StudentEditForm_Load(object sender, EventArgs e)
        {
            #region GetCities
            HttpResponseMessage responseCities = citiesService.GetResponse();
            List <City>         cities         = new List <City>();
            if (responseCities.IsSuccessStatusCode)
            {
                cities = responseCities.Content.ReadAsAsync <List <City> >().Result;
            }
            List <ComboItem> comboItems = new List <ComboItem>();

            foreach (City item in cities)
            {
                comboItems.Add(new ComboItem {
                    ID = item.CityID, Text = item.Name
                });
            }

            CityComboBox.DataSource = comboItems;
            #endregion

            if (responseCities.IsSuccessStatusCode)
            {
                ComboItem CityComboItem = new ComboItem();
                CityComboItem.ID   = (int)student.CityID;
                CityComboItem.Text = student.City.Name;


                CityComboBox.SelectedIndex = CityComboBox.FindString(student.City.Name);
            }
        }
        private void ClientsComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (clients.Count() > 0)
            {
                client = clients[ClientsComboBox.SelectedIndex];
                CityComboBox.SelectedIndex = CityComboBox.FindString(client.City.Name);

                FillDetails();
            }
        }
        private void GetClients()
        {
            HttpResponseMessage response = clientsService.GetResponse();

            if (response.IsSuccessStatusCode)
            {
                clients = response.Content.ReadAsAsync <List <Client> >().Result;

                List <ComboItem> comboItems = new List <ComboItem>();

                foreach (Client item in clients)
                {
                    comboItems.Add(new ComboItem {
                        ID = item.ClientID, Text = item.FirstName + " " + item.LastName
                    });
                }

                ClientsComboBox.DataSource = comboItems;
                client = clients[0];

                #region GetCities
                HttpResponseMessage responseCities = citiesServices.GetResponse();
                List <City>         cities         = new List <City>();
                if (responseCities.IsSuccessStatusCode)
                {
                    cities = responseCities.Content.ReadAsAsync <List <City> >().Result;
                }
                List <ComboItem> comboItems1 = new List <ComboItem>();

                foreach (City item in cities)
                {
                    comboItems1.Add(new ComboItem {
                        ID = item.CityID, Text = item.Name
                    });
                }

                CityComboBox.DataSource = comboItems1;
                #endregion

                if (responseCities.IsSuccessStatusCode)
                {
                    ComboItem CityComboItem = new ComboItem();
                    CityComboItem.ID   = (int)client.CityID;
                    CityComboItem.Text = client.City.Name;

                    CityComboBox.SelectedIndex = CityComboBox.FindString(client.City.Name); //(int)(client.CityID - 1);
                }
                FillDetails();
            }
            else
            {
                MessageBox.Show("Error Code" +
                                response.StatusCode + " : Message - " + response.ReasonPhrase);
            }
        }
示例#4
0
        private void MCUpdateButton_Click(object sender, EventArgs e)
        {//SAVE UPDATES
            if (String.IsNullOrEmpty(MCNameTextbox.Text))
            {
                MessageBox.Show("Please enter a name.");
                return;
            }
            if (String.IsNullOrEmpty(MCAddressTextbox.Text))
            {
                MessageBox.Show("Please enter an address.");
                return;
            }
            if (String.IsNullOrEmpty(MCZipTextbox.Text))
            {
                MessageBox.Show("Please enter a zip code.");
                return;
            }
            if (String.IsNullOrEmpty(MCPhoneButton.Text))
            {
                MessageBox.Show("Please enter a phone number.");
                return;
            }

            string ctyslct = CityComboBox.GetItemText(CityComboBox.SelectedItem);

            try
            {
                //UPDATE ADDRESS/CITY/COUNTRY
                string          Query = "Update address set address ='" + MCAddressTextbox.Text + "', cityId = '" + Globals.CtyID + "', postalCode = '" + MCZipTextbox.Text + "', phone = '" + MCPhoneButton.Text + "', lastUpdate ='" + TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss") + "', lastUpdateBy= '" + Globals.CurrUserName + "' Where addressId = '" + Globals.AddID + "';";
                MySqlConnection con2  = new MySqlConnection(Globals.connStr);
                MySqlCommand    comm  = new MySqlCommand(Query, con2);
                con2.Open();
                comm.ExecuteNonQuery();
                con2.Close();

                //UPDATECUSTOMER
                string          Queryx = "Update customer SET customerName = '" + MCNameTextbox.Text + "', lastUpdate ='" + TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss") + "', lastUpdateBy= '" + Globals.CurrUserName + "' WHERE customerId = '" + Globals.CustID + "';";
                MySqlConnection con2x  = new MySqlConnection(Globals.connStr);
                MySqlCommand    commx  = new MySqlCommand(Queryx, con2x);
                con2x.Open();
                commx.ExecuteNonQuery();
                MessageBox.Show("Data Saved");
            }
            catch (Exception)
            {
                MessageBox.Show("Could not update customer.", "Error");
            }

            this.Hide();
            Dashboard db = new Dashboard();

            db.ShowDialog();
        }
示例#5
0
        private void CityComboBox_DropDownClosed(object sender, EventArgs e)
        {
            string ctyslct = CityComboBox.GetItemText(CityComboBox.SelectedItem);

            using (MySqlConnection cmn = new MySqlConnection(Globals.connStr))
            {
                cmn.Open();
                MySqlCommand     mmmd = new MySqlCommand("SELECT cityId from city where city = '" + ctyslct + "';", cmn);
                MySqlDataAdapter mapt = new MySqlDataAdapter(mmmd);
                DataTable        mdm  = new DataTable();
                mapt.Fill(mdm);

                if (mdm.Rows.Count > 0)
                {
                    int idc = (int)mdm.Rows[0][0];
                    Globals.CtyID = idc;
                }
                cmn.Close();
            }
        }
示例#6
0
        private bool IsFormValid()
        {
            if (FullNameTextBox.Text.Trim() == string.Empty)
            {
                JIMessageBox.ShowErrorMessage("Full Name is required.");
                FullNameTextBox.Focus();
                return(false);
            }

            if (NICTextBox.Text.Trim() == string.Empty)
            {
                JIMessageBox.ShowErrorMessage("NIC is required");
                NICTextBox.Focus();
                return(false);
            }

            if ((MobileETextBox.Text.Trim() == string.Empty) && (TelephoneTextBox.Text.Trim() == string.Empty))
            {
                JIMessageBox.ShowErrorMessage("Number is required");
                return(false);
            }

            if (GenderComboBox.SelectedIndex == -1)
            {
                JIMessageBox.ShowErrorMessage("Gender is required");
                GenderComboBox.Focus();
                return(false);
            }

            if (AddressLineTextBox.Text.Trim() == string.Empty)
            {
                JIMessageBox.ShowErrorMessage("Address is required");
                AddressLineTextBox.Focus();
                return(false);
            }

            if (CityComboBox.Text.Trim() == string.Empty)
            {
                JIMessageBox.ShowErrorMessage("City is required");
                CityComboBox.Focus();
                return(false);
            }

            if (DistrictComboBox.Text.Trim() == string.Empty)
            {
                JIMessageBox.ShowErrorMessage("District is required");
                DistrictComboBox.Focus();
                return(false);
            }

            if (PostCodeBox.Text.Trim() == string.Empty)
            {
                JIMessageBox.ShowErrorMessage("Post Code is required");
                PostCodeBox.Focus();
                return(false);
            }

            if (JobTitleComboBox.Text.Trim() == string.Empty)
            {
                JIMessageBox.ShowErrorMessage("Job Title is required");
                JobTitleComboBox.Focus();
                return(false);
            }

            if (CurrentSalaryTextBox.Text.Trim() == string.Empty)
            {
                JIMessageBox.ShowErrorMessage("Current Salary is required");
                CurrentSalaryTextBox.Focus();
                return(false);
            }

            else
            {
                if (Convert.ToDecimal(CurrentSalaryTextBox.Text.Trim()) < 1)
                {
                    JIMessageBox.ShowErrorMessage("Current Salary Cannot be Zero or Less");
                    CurrentSalaryTextBox.Focus();
                    return(false);
                }
            }

            if (StartingSalaryTextBox.Text.Trim() == string.Empty)
            {
                JIMessageBox.ShowErrorMessage("Starting Salary is required");
                StartingSalaryTextBox.Focus();
                return(false);
            }

            else
            {
                if (Convert.ToDecimal(StartingSalaryTextBox.Text.Trim()) < 1)
                {
                    JIMessageBox.ShowErrorMessage("Starting Salary Cannot be Zero or Less");
                    StartingSalaryTextBox.Focus();
                    return(false);
                }
            }

            return(true);
        }
 private bool IsFormValid()
 {
     if (EmployeeNameTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Name is required");
         EmployeeNameTextBox.Focus();
         return(false);
     }
     if (CNICTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("CNIC is required");
         CNICTextBox.Focus();
         return(false);
     }
     if ((TelephoneTextBox.Text.Trim() == string.Empty) && (MobileTextBox.Text.Trim() == string.Empty))
     {
         Messages.ShowErrorMessage("Mobile number or Telephone number is required");
         MobileTextBox.Focus();
         return(false);
     }
     if (GenderComboBox.SelectedIndex == -1)
     {
         Messages.ShowErrorMessage("Gender is required");
         GenderComboBox.Focus();
         return(false);
     }
     //if (BranchComboBox.SelectedIndex == -1)
     //{
     //	Messages.ShowErrorMessage("Branch is required");
     //	BranchComboBox.Focus();
     //	return false;
     //}
     if (AddressLineTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Address Line is required");
         AddressLineTextBox.Focus();
         return(false);
     }
     if (CityComboBox.SelectedIndex == -1)
     {
         Messages.ShowErrorMessage("City is required");
         CityComboBox.Focus();
         return(false);
     }
     if (DistrictComboBox.SelectedIndex == -1)
     {
         Messages.ShowErrorMessage("District is required");
         DistrictComboBox.Focus();
         return(false);
     }
     if (PostalCodeTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Postal Code is required");
         PostalCodeTextBox.Focus();
         return(false);
     }
     if (JobTitleComboBox.SelectedIndex == -1)
     {
         Messages.ShowErrorMessage("Job Title is required");
         JobTitleComboBox.Focus();
         return(false);
     }
     if (StartingSalaryTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Starting Salary is required");
         StartingSalaryTextBox.Focus();
         return(false);
     }
     else
     {
         if (Convert.ToDecimal(StartingSalaryTextBox.Text) <= 0)
         {
             Messages.ShowErrorMessage("Starting Salary cannot be zero or less than zero");
             StartingSalaryTextBox.Focus();
             return(false);
         }
     }
     if (CurrentSalaryTextBox.Text.Trim() == string.Empty)
     {
         Messages.ShowErrorMessage("Current Salary is required");
         CurrentSalaryTextBox.Focus();
         return(false);
     }
     else
     {
         if (Convert.ToDecimal(CurrentSalaryTextBox.Text) <= 0)
         {
             Messages.ShowErrorMessage("Current Salary cannot be zero or less than zero");
             CurrentSalaryTextBox.Focus();
             return(false);
         }
     }
     return(true);
 }
示例#8
0
 private void SendGroupView_Loaded(object sender, RoutedEventArgs e)
 {
     //(DepoComboBox as TextBoxBase).TextChanged += SendGroupView_TextChanged;
     CityComboBox.AddHandler(TextBoxBase.TextChangedEvent, new RoutedEventHandler(OnDepoComboBoxTextChanged));
     DepoComboBox.AddHandler(TextBoxBase.TextChangedEvent, new RoutedEventHandler(OnDepoComboBoxTextChanged));
 }