private void Edit() { try { int selectedColumn = GridViewContact.CurrentCell.ColumnIndex; DataGridViewColumn selectcolumn = GridViewContact.Columns[selectedColumn]; if (selectcolumn.HeaderText == "Edit") { int selectedrow = GridViewContact.SelectedCells[0].RowIndex; DataGridViewRow selectRow = GridViewContact.Rows[selectedrow]; DataTable dt = new DataTable(); dt = new Bll.AddressBook().GetGrideData(" and con.ContactID=" + selectRow.Cells["ContactID"].Value.ToString() + ""); if (dt.Rows.Count > 0) { this.btnSave.Text = "Update"; AssigntoControls(dt); EnableSearch(false); btNew.Enabled = false; } else { throw (new Exception("Unable To Load Info!")); } } } catch (Exception exception) { throw exception; } }
private void Edit() { try { int selectedColumn = gdvCategory.CurrentCell.ColumnIndex; DataGridViewColumn selectcolumn = gdvCategory.Columns[selectedColumn]; if (selectcolumn.HeaderText == "Edit") { int selectedrow = gdvCategory.SelectedCells[0].RowIndex; DataGridViewRow selectRow = gdvCategory.Rows[selectedrow]; //DataTable dt = null; dt = new Bll.AddressBook().GetAllCatagories(" and CategoryID = " + selectRow.Cells["CategoryID"].Value.ToString() + ""); if (dt.Rows.Count > 0) { btSave.Text = "Update"; AssigntoControls(dt); EnableSearch(true); btNew.Enabled = false; } else { throw (new Exception("Unable To Load Doctor Info!")); } } } catch (Exception exception) { throw exception; } }
private void FrmMainWindow_Load(object sender, EventArgs e) { ///LOAD CBO CATAGORY /////////option 1 dtCatagories = new Bll.AddressBook().GetAllCatagories(""); DataRow rowCatagories = dtCatagories.NewRow(); rowCatagories["CategoryID"] = "0"; rowCatagories["CategoryName"] = "All"; dtCatagories.Rows.InsertAt(rowCatagories, 0); //DataView dv1 = new DataView(dtCatagories); this.cbxCategory.DataSource = dtCatagories; /////////option 2 //this.cbxCategory.DataSource = new Bll.MainWindow().GetAllCatagories(); ///////// //this.cbxCategory.ValueMember = "CategoryID"; //this.cbxCategory.DisplayMember = "CategoryName"; this.cbxCategory.SelectedIndex = 0; ///LOAD CBO CATAGORY ///LOAD GRID loadGrid(); ///LOAD GRID //load cbo of search //DataView dv2 = new DataView(dtCatagories); //this.cboCaegorySearch.DataSource = dv2; //this.cboCaegorySearch.ValueMember = "CategoryID"; //this.cboCaegorySearch.DisplayMember = "CategoryName"; //this.cboCaegorySearch.SelectedIndex = 0; dtCatagories = new Bll.AddressBook().GetAllCatagories(""); rowCatagories = dtCatagories.NewRow(); rowCatagories["CategoryID"] = "0"; rowCatagories["CategoryName"] = "All"; dtCatagories.Rows.InsertAt(rowCatagories, 0); cbxCaegorySearch.DataSource = dtCatagories; this.cbxCaegorySearch.SelectedIndex = 0; //load cbo of search //load cbo of city DataTable dt = new Bll.AddressBook().GetCity(" and City is not null group by city"); rowCatagories = dt.NewRow(); rowCatagories["City"] = "All"; dt.Rows.InsertAt(rowCatagories, 0); this.cboCity.DataSource = dt; //this.cboCity.DataSource = new Bll.AddressBook().GetCity(""); //load cbo of city EnableSearch(true); }
private void GridViewContact_SelectionChanged(object sender, EventArgs e) { if (ActiveControl == null) { return; } else if (ActiveControl.Name != this.GridViewContact.Name) { return; } try { if (GridViewContact.Rows.Count > 0) { int selectedrow = GridViewContact.CurrentCell.RowIndex; DataGridViewRow selectRow = GridViewContact.Rows[GridViewContact.CurrentCell.RowIndex]; ctrlClear(); DataTable dt = new DataTable(); dt = null; //dt = Biz_Doctors.getDataTable(" and DoctorID = " + selectRow.Cells["DoctorID"].Value.ToString()); dt = new Bll.AddressBook().GetGrideData(" and con.ContactID=" + selectRow.Cells["ContactID"].Value.ToString() + ""); if (dt.Rows.Count > 0) { AssigntoControls(dt); } else { } } } catch (Exception Exception) { MessageBox.Show("GridViewSearch_SelectionChanged Error\n" + Exception + "", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CallRecords_Load(object sender, EventArgs e) { ///LOAD CBO CATAGORY //dtCatagories = new Bll.MainWindow().GetAllCatagories(""); //DataRow rowCatagories = dtCatagories.NewRow(); //rowCatagories["CategoryID"] = "0"; //rowCatagories["CategoryName"] = "All"; //dtCatagories.Rows.InsertAt(rowCatagories, 0); //DataView dv1 = new DataView(dtCatagories); this.cbxCategory.DataSource = new Bll.AddressBook().GetAllCatagories(""); this.cbxCategory.SelectedIndex = 0; ///LOAD CBO CATAGORY ///LOAD GRID loadGrid(); this.GridViewCallRecords.Columns["CallDateTime"].DefaultCellStyle.Format = "dd-MMM-yyyy HH:mm:ss"; ///LOAD GRID //load cbo of search //DataView dv2 = new DataView(dtCatagories); dtCatagories = new Bll.AddressBook().GetAllCatagories(""); DataRow rowCatagories = dtCatagories.NewRow(); rowCatagories["CategoryID"] = "0"; rowCatagories["CategoryName"] = "All"; dtCatagories.Rows.InsertAt(rowCatagories, 0); cbxCaegorySearch.DataSource = dtCatagories; this.cbxCaegorySearch.SelectedIndex = 0; //load cbo of search //load cbo for persones this.cbxContactPerson.DataSource = new Bll.CallRecords().GetPersons(""); //load cbo for persones //load cbo of city DataTable dt = new Bll.AddressBook().GetCity(" and City is not null group by city"); rowCatagories = dt.NewRow(); rowCatagories["City"] = "Any/NA/All"; dt.Rows.InsertAt(rowCatagories, 0); DataView dv1 = new DataView(dt); this.cboCity.DataSource = dv1; //load cbo of city //load cbo of city for search DataView dv2 = new DataView(dt); this.cboCitySearch.DataSource = dv2; //load cbo of city for search EnableSearch(false); this.cbxContactPerson.Text = string.Empty; }