}//make Cascade private void Populate_AddrGridView(String contractID) { if (_contractForm != null) { try { _contractForm.ClearGridView(); } catch (Exception) { } DataTable srvAddrs = MServiceAddress.GetAllAddrs(contractID); String rowID; String[] rowData; for (int i = 0; i < srvAddrs.Rows.Count; i++) { rowID = srvAddrs.Rows[i].ItemArray[0].ToString(); NewSrvAddr(); rowData = _srvAddr.Get(rowID); _contractForm.Add_Old_Row(rowData); } } }
/********************************* Service Address Grid View *****************************/ private void ServiceAddrGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { var c = ServiceAddrGridView.Rows[e.RowIndex].Cells["countryCol"] as DataGridViewComboBoxCell; DataTable dt = MCountry.GetList(); c.DataSource = dt; c.DisplayMember = "name"; c.ValueMember = "id"; MServiceAddress _srvAddr = new MServiceAddress(); ServiceAddrGridView.Rows[e.RowIndex].Cells[0].Value = _srvAddr.FindID(); ServiceAddrGridView.Rows[e.RowIndex].Cells["editButton"].Value = "0"; ServiceAddrGridView.Rows[e.RowIndex].Cells["roomButton"].Value = "0"; ServiceAddrGridView.Rows[e.RowIndex].Cells["num_floors"].Value = "0"; }
private static void NewSrvAddr() { _srvAddr = new MServiceAddress(); }
/************************* Add Edit Contract Form Events *****************************************/ public void Contract_Cell_Click(object sender, DataGridViewCellEventArgs e) { var dgv = sender as DataGridView; if ((e.ColumnIndex == 9) && (e.RowIndex > -1))//-----------------------------------Edit { #region Edit if (_contractForm.GetEndDate().ToShortDateString() != DateTime.Today.ToShortDateString()) { NewSrvAddr(); string addr = "<No Address>"; String addrID = dgv.Rows[e.RowIndex].Cells[0].Value.ToString(); try { addr = dgv.Rows[e.RowIndex].Cells["address_col"].Value.ToString(); } catch (NullReferenceException) { } _srvAddrForm = new AddEditSrvAddrForm(this, addr, addrID, e.RowIndex); try { _srvAddrForm.setFields(MContractServices.GetAll(addrID)); } catch (Exception) { } // _srvAddrForm.Activate(); _srvAddrForm.ShowDialog(); _srvAddrForm.setDate(_contractForm.GetStartDate()); _contractForm.SetTableButtonMetrics(e.RowIndex, addrID); } else { MessageBox.Show("Please specify the end date of the contract.", "Incomplete Contract", MessageBoxButtons.OKCancel); } #endregion } if ((e.ColumnIndex == 8) && (e.RowIndex > -1))// ----------------------------------Room { #region Room //int k = arg.RowIndex; String addrID = dgv.Rows[e.RowIndex].Cells["idCol"].Value.ToString(); NewSrvAddr(); _roomForm = new AddEditRoomForm(this, addrID, e.RowIndex); _roomForm.Activate(); _roomForm.ShowDialog(); _contractForm.SetTableButtonMetrics(e.RowIndex, addrID); return; #endregion } if ((e.ColumnIndex == 10) && (e.RowIndex > -1))//-----------------------------------Remove { #region Remove try { string id = dgv.Rows[e.RowIndex].Cells["idCol"].Value.ToString(); MServiceAddress.Delete(id, "Service_Address", "service_addres_id"); } catch (Exception) { } dgv.Rows.RemoveAt(e.RowIndex); #endregion } else//---------------------------------------------------------------------------Other { return; } }
public string AddBlankAddr() { MServiceAddress sa = new MServiceAddress(); return sa.AddBlank(); }