private void BWICarchivedCheckBox_CheckedChanged(object sender, EventArgs e) { string strVal; int i; strVal = ""; //MessageBox.Show(BWICarchivedCheckBox.CheckState.ToString() ); if (BWICarchivedCheckBox.CheckState.ToString().Equals("Checked")) { archived = true; } else { archived = false; } //*** READ DATES AND NOTE THE ONES THAT ARE CHECKED i = 0; while (i < BWICdatecheckedListBox.Items.Count) { strVal = BWICdatecheckedListBox.Items[i].ToString(); if (strVal.IndexOf(":") > 0) { strVal = strVal.Substring(0, strVal.IndexOf(":")); } if (BWICdatecheckedListBox.GetItemChecked(i)) { lBWICDates.Add(strVal); } i++; } i = 0; while (i < BWICListcheckedListBox.Items.Count) { strVal = BWICListcheckedListBox.Items[i].ToString(); if (strVal.IndexOf(":") > 0) { strVal = strVal.Substring(0, strVal.IndexOf(":")); } if (BWICListcheckedListBox.GetItemChecked(i)) { lBWICLists.Add(strVal); } i++; } fillBWICdate(); BWICListcheckedListBox.Items.Clear(); //fillBWIClist(); i = 0; while (i < BWICdatecheckedListBox.Items.Count) { strVal = BWICdatecheckedListBox.Items[i].ToString(); if (strVal.IndexOf(":") > 0) { strVal = strVal.Substring(0, strVal.IndexOf(":")); } foreach (object element in lBWICDates) { //MessageBox.Show(element.ToString()); if (strVal.Equals(element.ToString())) { BWICdatecheckedListBox.SetItemChecked(i, true); } } i++; } i = 0; while (i < BWICListcheckedListBox.Items.Count) { strVal = BWICListcheckedListBox.Items[i].ToString(); if (strVal.IndexOf(":") > 0) { strVal = strVal.Substring(0, strVal.IndexOf(":")); } foreach (object element in lBWICLists) { //MessageBox.Show(element.ToString()); if (strVal.Equals(element.ToString())) { BWICListcheckedListBox.SetItemChecked(i, true); } } i++; } //foreach (object element in lBWICDates) //{ // MessageBox.Show(element.ToString()); //} //fillBWICdate(); lBWICDates.Clear(); lBWICLists.Clear(); }
private void deleteBWICdate(string criteria) { int i; string SQL; string lstID; string[] txtFlds; txtFlds = new string[2]; i = 0; lstID = ""; if (criteria.LastIndexOf(":") > 0) { criteria = criteria.Substring(0, criteria.LastIndexOf(":")); } if (usingSQLServer == false) { } SQL = "select BWIC_NAME, COUNT(*) AS CNT from BWICinventory where " + " FILE_DATE='" + criteria + "' group by bwic_name;"; if (usingSQLServer == true) { SqlConnection cn = new SqlConnection("Data Source=ZM-SQL-1;" + "Initial Catalog=ZM_GALLAGHER; Integrated Security=SSPI;"); cn.Open(); SqlCommand cmd = new SqlCommand(); cmd = cn.CreateCommand(); SqlDataReader rdr; cmd.CommandText = SQL; rdr = cmd.ExecuteReader(); while (rdr.Read()) { txtFlds[0] = rdr.GetValue(0).ToString(); txtFlds[1] = rdr.GetValue(1).ToString(); //MessageBox.Show("OUTER:" + txtFlds[0].ToString()); i = 0; while (i < BWICListcheckedListBox.Items.Count) { lstID = BWICListcheckedListBox.Items[i].ToString(); if (lstID.LastIndexOf(":") > 0) { lstID = lstID.Substring(0, lstID.LastIndexOf(":")); } if (txtFlds[0].Equals(lstID)) { //MessageBox.Show("Match:" + txtFlds[0].ToString()); if (BWICListcheckedListBox.GetItemCheckState(i).ToString().Equals("Checked")) { deleteBWICList("", BWICListcheckedListBox.Items[i].ToString()); } BWICListcheckedListBox.Items.RemoveAt(i); } //MessageBox.Show(lstID); //MessageBox.Show(BWICListcheckedListBox.Items[i].ToString()); i++; } //BWICListcheckedListBox.Items.Add(txtFlds[0] + ": \t" + txtFlds[1], false); } rdr.Close(); cn.Close(); } }