Exemple #1
0
        private void BAddrGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            BAddrGridView.CellValueChanged -= BAddrGridView_CellValueChanged;
            if ((e.ColumnIndex == 3) && (e.RowIndex > -1))//--------------------------------Country
            {
                DataGridViewComboBoxCell province = BAddrGridView.Rows[e.RowIndex].Cells["bProvince"] as DataGridViewComboBoxCell;
                DataTable pr = MProvState.GetFilteredList(BAddrGridView.Rows[e.RowIndex].Cells["bcountry"].Value.ToString());
                province.DataSource    = pr;
                province.DisplayMember = pr.Columns[1].ToString();
                province.ValueMember   = pr.Columns[0].ToString();
                noChanges = false;
            }
            if ((e.ColumnIndex == 4) && (e.RowIndex > -1))//--------------------------------Province
            {
                DataGridViewComboBoxCell city = BAddrGridView.Rows[e.RowIndex].Cells["bCity"] as DataGridViewComboBoxCell;
                DataTable ci = MCity.GetFilteredList(BAddrGridView.Rows[e.RowIndex].Cells["bProvince"].Value.ToString());
                city.DataSource    = ci;
                city.DisplayMember = ci.Columns[1].ToString();
                city.ValueMember   = ci.Columns[0].ToString();
                noChanges          = false;
            }
            if ((e.ColumnIndex == 5) && (e.RowIndex > -1))//--------------------------------City
            {
                noChanges = false;
            }
            else
            {
                noChanges = false;
            }

            BAddrGridView.CellValueChanged += new DataGridViewCellEventHandler(BAddrGridView_CellValueChanged);
        }
Exemple #2
0
        static public String[] FindCred(String ID)
        {
            String[]      result     = new String[6];
            String        connString = Properties.Settings.Default.HQ;
            DataTable     dt1        = new DataTable();
            DataTable     dt2        = new DataTable();
            SqlConnection con        = new SqlConnection(connString);

            con.Open();
            SqlCommand     command1 = new SqlCommand("SELECT * FROM Franchisee  WHERE franchisee_id = " + ID, con);
            SqlDataAdapter adap1    = new SqlDataAdapter(command1);

            adap1.Fill(dt1);

            SqlCommand     command2 = new SqlCommand("SELECT * FROM Operational_Region  WHERE zone_id = " + dt1.Rows[0]["zone_id"].ToString(), con);
            SqlDataAdapter adap2    = new SqlDataAdapter(command2);

            adap2.Fill(dt2);
            con.Close();

            result[0] = dt1.Rows[0]["company_name"].ToString();
            result[1] = dt1.Rows[0]["isHQ"].ToString();
            result[2] = dt2.Rows[0]["zone_title"].ToString();
            result[3] = MCountry.GetName(dt2.Rows[0]["country_id"].ToString());
            result[4] = MProvState.GetName(dt2.Rows[0]["province_id"].ToString());
            result[5] = MCity.GetName(dt2.Rows[0]["city_id"].ToString());


            return(result);
        }
Exemple #3
0
 public void Province_Changed(object sender, EventArgs e)
 {
     if (_clientForm.GetProvStateBox() != "System.Data.DataRowView")
     {
         if (_clientForm.GetProvStateBox() != "-1")
         {
             String provID = _clientForm.GetProvStateBox();
             if (provID != null)
             {
                 _client.changeProvince(provID);
                 _clientForm.SetCityBox(MCity.GetFilteredList(provID));
             }
         }
     }
 }
Exemple #4
0
        public void Add_Old_Row(String[] rowElements)
        {
            int index = ServiceAddrGridView.Rows.Add();

            SetTableButtonMetrics(index, rowElements[0]);

            DataTable country, province, city;

            country  = MCountry.GetList();
            province = MProvState.GetFilteredList(rowElements[6]);
            city     = MCity.GetFilteredList(rowElements[5]);


            //country.TableName = "country";
            var countryCell = ServiceAddrGridView.Rows[index].Cells["countryCol"] as DataGridViewComboBoxCell;

            //(ServiceAddrGridView.Rows[index].Cells[0].DataPropertyName = "Type";
            countryCell.DataSource    = country;
            countryCell.DisplayMember = "name";
            countryCell.ValueMember   = "id";

            var provCell = ServiceAddrGridView.Rows[index].Cells["provStateCol"] as DataGridViewComboBoxCell;

            provCell.DataSource    = province;
            provCell.DisplayMember = "name";
            provCell.ValueMember   = "id";

            var cityCell = ServiceAddrGridView.Rows[index].Cells["cityCol"] as DataGridViewComboBoxCell;

            cityCell.DataSource    = city;
            cityCell.DisplayMember = "name";
            cityCell.ValueMember   = "id";

            ServiceAddrGridView.Rows[index].Cells["idCol"].Value               = rowElements[0];
            ServiceAddrGridView.Rows[index].Cells["address_col"].Value         = rowElements[1];
            ServiceAddrGridView.Rows[index].Cells["postal_code_col"].Value     = rowElements[2];
            ServiceAddrGridView.Rows[index].Cells["on_site_contact_col"].Value = rowElements[3];
            try
            {
                ServiceAddrGridView.Rows[index].Cells["countryCol"].Value   = rowElements[4];
                ServiceAddrGridView.Rows[index].Cells["provStateCol"].Value = rowElements[5];
                ServiceAddrGridView.Rows[index].Cells["cityCol"].Value      = rowElements[6];
            }
            catch (Exception) { }
            ServiceAddrGridView.Rows[index].Cells["num_floors"].Value = rowElements[7];
            ServiceAddrGridView.Rows[index].Cells["roomButton"].Value = rowElements[8];
        }
        public void InitializeCombos(String countryID, String ProvID, String CityID)
        {
            DataTable country = MCountry.GetList();
            DataTable province;
            DataTable city;

            if (String.Equals(countryID, "noChange"))
            {
                province = MProvState.GetFilteredList(CountryBox.SelectedValue.ToString());
            }
            else
            {
                CountryBox.SelectedValueChanged -= CountryBoxChanged;
                CountryBox.DataSource            = country;
                CountryBox.DisplayMember         = country.Columns[1].ToString();
                CountryBox.ValueMember           = country.Columns[0].ToString();
                province = MProvState.GetFilteredList(countryID);
                CountryBox.SelectedValueChanged += new EventHandler(CountryBoxChanged);
            }


            if (String.Equals(ProvID, "noChange"))
            {
                city = MCity.GetFilteredList(ProvStateBox.SelectedValue.ToString());
            }
            else
            {
                ProvStateBox.SelectedValueChanged -= ProvBoxChanged;
                ProvStateBox.DataSource            = province;
                ProvStateBox.DisplayMember         = province.Columns[1].ToString();
                ProvStateBox.ValueMember           = province.Columns[0].ToString();
                city = MCity.GetFilteredList(ProvID);
                ProvStateBox.SelectedValueChanged += new EventHandler(ProvBoxChanged);
            }


            CityBox.DataSource    = city;
            CityBox.DisplayMember = city.Columns[1].ToString();
            CityBox.ValueMember   = city.Columns[0].ToString();
        }
Exemple #6
0
        void ServiceAddrGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if ((e.ColumnIndex == 4) && e.RowIndex > -1)//------------------------------CountryBox
            {
                try
                {
                    String countryID = ServiceAddrGridView.Rows[e.RowIndex].Cells["countryCol"].Value.ToString();
                    var    provCell  = ServiceAddrGridView.Rows[e.RowIndex].Cells["provStateCol"] as DataGridViewComboBoxCell;

                    DataTable provList = MProvState.GetFilteredList(countryID);
                    provCell.DataSource    = provList;
                    provCell.DisplayMember = "name";
                    provCell.ValueMember   = "id";
                    noChanges = false;
                }
                catch (Exception) { }
            }

            if ((e.ColumnIndex == 5) && e.RowIndex > -1)//-------------------------------- ProvBox
            {
                try
                {
                    String    provID   = ServiceAddrGridView.Rows[e.RowIndex].Cells["provStateCol"].Value.ToString();
                    var       cityCell = ServiceAddrGridView.Rows[e.RowIndex].Cells["cityCol"] as DataGridViewComboBoxCell;
                    DataTable cityList = MCity.GetFilteredList(provID);

                    cityCell.DataSource    = cityList;
                    cityCell.DisplayMember = "name";
                    cityCell.ValueMember   = "id";
                    noChanges = false;
                }
                catch (Exception) { }
            }

            if ((e.ColumnIndex == 6) && e.RowIndex > -1)//---------------------------------- City
            {
                noChanges = false;
            }
        }
Exemple #7
0
        public void LoadOpRegions()
        {
            DataTable dt   = MOpReg.GetRegions();
            DataTable regs = new DataTable();

            regs.Columns.Add("ID", typeof(string));
            regs.Columns.Add("Display", typeof(string));

            regs.Rows.Add(new String[] { "NULL", "<All>" });
            foreach (DataRow r in dt.Rows)
            {
                regs.Rows.Add(r["zone_id"].ToString(), r["zone_Title"].ToString() + " ( "
                              + MCity.GetName(r["city_id"].ToString()) + ", "
                              + MProvState.GetName(r["province_id"].ToString()) + ", "
                              + MCountry.GetName(r["country_id"].ToString()) + ")");
            }

            OpRegionCombo.DataSource    = regs;
            OpRegionCombo.ValueMember   = regs.Columns["ID"].ToString();
            OpRegionCombo.DisplayMember = regs.Columns["Display"].ToString();
            OpRegionCombo.SelectedValue = "NULL";
        }
Exemple #8
0
        public void PopulateBAddrsGridView(DataTable Addrs)
        {
            DataGridViewComboBoxCell country;
            DataTable co = MCountry.GetList();
            DataGridViewComboBoxCell province;
            DataTable pr;
            DataGridViewComboBoxCell city;
            DataTable ci;
            int       n = Addrs.Rows.Count, index;

            for (int i = 0; i < n; i++)
            {
                index = BAddrGridView.Rows.Add();
                BAddrGridView.Rows[index].Cells["locID"].Value   = Addrs.Rows[i]["location_id"];
                BAddrGridView.Rows[index].Cells["bAddr"].Value   = Addrs.Rows[i]["address"];
                BAddrGridView.Rows[index].Cells["bPostal"].Value = Addrs.Rows[i]["postal_code"];

                country               = BAddrGridView.Rows[index].Cells["bCountry"] as DataGridViewComboBoxCell;
                country.DataSource    = co;
                country.DisplayMember = co.Columns[1].ToString();
                country.ValueMember   = co.Columns[0].ToString();
                country.Value         = Addrs.Rows[i]["country_id"];

                province               = BAddrGridView.Rows[index].Cells["bProvince"] as DataGridViewComboBoxCell;
                pr                     = MProvState.GetFilteredList(Addrs.Rows[i]["country_id"].ToString());
                province.DataSource    = pr;
                province.DisplayMember = pr.Columns[1].ToString();
                province.ValueMember   = pr.Columns[0].ToString();
                province.Value         = Addrs.Rows[i]["province_id"];

                city               = BAddrGridView.Rows[index].Cells["bCity"] as DataGridViewComboBoxCell;
                ci                 = MCity.GetFilteredList(Addrs.Rows[i]["province_id"].ToString());
                city.DataSource    = ci;
                city.DisplayMember = ci.Columns[1].ToString();
                city.ValueMember   = ci.Columns[0].ToString();
                city.Value         = Addrs.Rows[i]["city_id"];
            }
        }
Exemple #9
0
        private void AddAddrButton_Click(object sender, EventArgs e)
        {
            int i = BAddrGridView.Rows.Add();
            DataGridViewComboBoxCell country = BAddrGridView.Rows[i].Cells["bCountry"] as DataGridViewComboBoxCell;
            DataTable co = MCountry.GetList();

            country.DataSource    = co;
            country.DisplayMember = co.Columns[1].ToString();
            country.ValueMember   = co.Columns[0].ToString();

            DataGridViewComboBoxCell province = BAddrGridView.Rows[i].Cells["bProvince"] as DataGridViewComboBoxCell;
            DataTable pr = MProvState.GetFilteredList("1");

            province.DataSource    = pr;
            province.DisplayMember = pr.Columns[1].ToString();
            province.ValueMember   = pr.Columns[0].ToString();

            DataGridViewComboBoxCell city = BAddrGridView.Rows[i].Cells["bCity"] as DataGridViewComboBoxCell;
            DataTable ci = MCity.GetFilteredList("1");

            city.DataSource    = ci;
            city.DisplayMember = ci.Columns[1].ToString();
            city.ValueMember   = ci.Columns[0].ToString();
        }