コード例 #1
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            try
            {
                TotalColumnList obj = new TotalColumnList();
                obj.SheetName = lblSheetName.Text;
                if (cbxAddress_Line1.SelectedIndex != 0)
                {
                    obj.Addressline1col = cbxAddress_Line1.SelectedValue.ToString();
                }
                else
                {
                    obj.Addressline1col = "";
                }
                if (cbxAddressLine_2.SelectedIndex != 0)
                {
                    obj.AddressLine2col = cbxAddressLine_2.SelectedValue.ToString();
                }
                else
                {
                    obj.AddressLine2col = "";
                }

                if (cbxzip.SelectedIndex != 0)
                {
                    obj.Zipcol = cbxzip.SelectedValue.ToString();
                }
                else
                {
                    obj.Zipcol = "";
                }
                if (cbxState.SelectedIndex != 0)
                {
                    obj.Statecol = cbxState.SelectedValue.ToString();
                }
                else
                {
                    obj.Statecol = "";
                }
                if (cbxCity.SelectedIndex != 0)
                {
                    obj.Citycol = cbxCity.SelectedValue.ToString();
                }
                else
                {
                    obj.Citycol = "";
                }
                if (cbxHouseNo.SelectedIndex != 0)
                {
                    obj.Housenocol = cbxHouseNo.SelectedValue.ToString();
                }
                else
                {
                    obj.Housenocol = "";
                }

                //if (obj.Addressline1col == "")
                //{
                //    lblAddress1.Visible = true;
                //    lblAddress1.Text = "Address Required";
                //    lblAddress1.ForeColor = Color.Red;
                //}
                //else if (obj.Zipcol == "")
                //{
                //    lblZipCode.Visible = true;
                //    lblZipCode.Text = "Zip Code Required";
                //    lblZipCode.ForeColor = Color.Red;
                //}
                //else
                //{

                FullColumnList.Add(obj);
                var fileupload = new UploadFile();
                fileupload.Show();
                this.Hide();
                //}
            }
            catch (Exception ex)
            {
                Logger.Log(ex, null);
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void btnNextSheet_Click(object sender, EventArgs e)
        {
            try
            {
                var SheetNamesList = USPSCleanUp.UploadFile.dtsheetName;
                if (SheetNamesList.Count <= sheetCount + 1)
                {
                    TotalColumnList obj = new TotalColumnList();
                    obj.SheetName = lblSheetName.Text;
                    var first = SheetNamesList[sheetCount].ToString();
                    lblSheetName.Text = first;

                    if (cbxAddress_Line1.SelectedIndex != 0)
                    {
                        obj.Addressline1col = cbxAddress_Line1.SelectedValue.ToString();
                    }
                    else
                    {
                        obj.Addressline1col = "";
                    }
                    if (cbxAddressLine_2.SelectedIndex != 0)
                    {
                        obj.AddressLine2col = cbxAddressLine_2.SelectedValue.ToString();
                    }
                    else
                    {
                        obj.AddressLine2col = "";
                    }

                    if (cbxzip.SelectedIndex != 0)
                    {
                        obj.Zipcol = cbxzip.SelectedValue.ToString();
                    }
                    else
                    {
                        obj.Zipcol = "";
                    }
                    if (cbxState.SelectedIndex != 0)
                    {
                        obj.Statecol = cbxState.SelectedValue.ToString();
                    }
                    else
                    {
                        obj.Statecol = "";
                    }
                    if (cbxCity.SelectedIndex != 0)
                    {
                        obj.Citycol = cbxCity.SelectedValue.ToString();
                    }
                    else
                    {
                        obj.Citycol = "";
                    }
                    if (cbxHouseNo.SelectedIndex != 0)
                    {
                        obj.Housenocol = cbxHouseNo.SelectedValue.ToString();
                    }
                    else
                    {
                        obj.Housenocol = "";
                    }



                    if (obj.Addressline1col == "")
                    {
                        lblAddress1.Visible   = true;
                        lblAddress1.Text      = "Address Required";
                        lblAddress1.ForeColor = Color.Red;
                    }
                    else if (obj.Zipcol == "")
                    {
                        lblZipCode.Visible   = true;
                        lblZipCode.Text      = "Zip Code Required";
                        lblZipCode.ForeColor = Color.Red;
                    }
                    USPSCleanUp.UploadFile.ColumnList.Clear();
                    foreach (DataColumn dc in USPSCleanUp.UploadFile.dt.Tables[first].Columns)
                    {
                        string collist = dc.ToString();
                        USPSCleanUp.UploadFile.ColumnList.Add(collist);
                    }
                    //var filename = USPSCleanUp.UploadFile.onlyFileName;
                    var ColumnList = USPSCleanUp.UploadFile.ColumnList;
                    ColumnList.Insert(0, "--Select--");
                    cbxAddress_Line1.DataSource = new BindingSource(ColumnList, null);
                    cbxAddressLine_2.DataSource = new BindingSource(ColumnList, null);
                    cbxzip.DataSource           = new BindingSource(ColumnList, null);
                    cbxState.DataSource         = new BindingSource(ColumnList, null);
                    cbxCity.DataSource          = new BindingSource(ColumnList, null);
                    cbxHouseNo.DataSource       = new BindingSource(ColumnList, null);
                    sheetCount += 1;
                    if (sheetCount == SheetNamesList.Count)
                    {
                        if (sheetCount == 2)
                        {
                            btnSkip.Visible = true;
                        }
                        btnRun.Visible       = true;
                        btnNextSheet.Visible = false;
                    }
                    else
                    {
                        if (sheetCount == 2)
                        {
                            btnSkip.Visible = true;
                        }
                        btnRun.Visible       = false;
                        btnNextSheet.Visible = true;
                    }

                    FullColumnList.Add(obj);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex, null);
                MessageBox.Show(ex.Message);
            }
        }