public void LoadData() { string revQuery = "Select CompanyName = CASE " + "WHEN NickName IS NULL THEN [CompanyName] " + "WHEN NickName = '' THEN [CompanyName] " + "ELSE NickName " + "END From " + "Contact Where ContactType=2 and " + "ContactStatus=1 Order By CompanyName"; IDataReader reader = DAC.SelectStatement(revQuery); if (_mode == "Add") { while(reader.Read()) { if (reader["CompanyName"] != DBNull.Value) { cmbClient.Items.Remove(reader["CompanyName"].ToString()); } } cmbClient.Text = String.Empty; cmbClient.Tag = String.Empty; cmbStatus.SelectedIndex = 0; txtCompName.Text = String.Empty; txtCompName.Tag = String.Empty; chkNoDept.Checked = false; txtCompPhonetic.Text = String.Empty; txtCompRomaji.Text = String.Empty; txtNickName.Text = String.Empty; txtNickName.Tag = String.Empty; txtAccLName.Text = String.Empty; txtAccLPhonetic.Text = String.Empty; txtAccLRomaji1.Text = String.Empty; txtAccFirstName.Text = String.Empty; txtAccFirstPhonetic.Text = String.Empty; txtAccFirstRomaji.Text = String.Empty; cmbBlock.Text = String.Empty; txtStreet1.Text = String.Empty; txtStreet2.Text = String.Empty; txtStreet3.Text = String.Empty; txtCity.Text = String.Empty; txtState.Text = String.Empty; txtPost.Text = String.Empty; txtCountry.Text = String.Empty; txtPhone1.Text = String.Empty; txtPhone2.Text = String.Empty; txtFax1.Text = String.Empty; txtFax2.Text = String.Empty; txtPhoneOther.Text = String.Empty; txtUrl.Text = String.Empty; dtJoined.Value = dtEnded.Value = DateTime.Now; dtJoined.Checked = true; dtEnded.Checked = true; txtMintSt1.Text = String.Empty; txtClosestSt1.Text = String.Empty; txtClosestLine1.Text = String.Empty; txtMintSt2.Text = String.Empty; txtClosestSt2.Text = String.Empty; txtClosestLine2.Text = String.Empty; cmbStatus.SelectedIndex = 0; } else { //Calling the Dept. class file int intClientID=0; int intStatus=0; Department objDept=new Department(); objDept.DeptID = _deptid; objDept.LoadData(); //read the values intClientID = objDept.ClientID; intContactID = objDept.ContactID; cmbClient.Text = objDept.ClientName; while (reader.Read()) { if (reader["CompanyName"] != DBNull.Value && reader["CompanyName"].ToString() != objDept.ClientName) { cmbClient.Items.Remove(reader["CompanyName"].ToString()); } } cmbClient.Tag = objDept.ClientName; intStatus = objDept.StatusID; cmbStatus.SelectedIndex=intStatus; //Getting data from Contact Table Contact objContact=new Contact(); objContact.ContactID = _contactid; objContact.LoadData("Department"); foreach(DataRow dr in objContact.dtblContacts.Rows) { txtCompName.Text = dr["CompanyName"].ToString(); txtCompName.Tag = dr["CompanyName"].ToString(); if (txtCompName.Text == "No Department") chkNoDept.Checked = true; else if (_mode == "AddClone") txtCompName.Text = "Copy of " + txtCompName.Text; txtCompPhonetic.Text = dr["CompanyNamePhonetic"].ToString(); txtCompRomaji.Text = dr["CompanyNameRomaji"].ToString(); txtNickName.Text = dr["NickName"].ToString(); txtNickName.Tag = txtNickName.Text; txtAccLName.Text = dr["AccountRepLastName"].ToString(); txtAccLPhonetic.Text = dr["AccountRepLastNamePhonetic"].ToString(); txtAccLRomaji1.Text = dr["AccountRepLastNameRomaji"].ToString(); txtAccFirstName.Text = dr["AccountRepFirstName"].ToString(); txtAccFirstPhonetic.Text = dr["AccountRepFirstNamePhonetic"].ToString(); txtAccFirstRomaji.Text = dr["AccountRepFirstNameRomaji"].ToString(); if(dr["BlockCode"].ToString().Trim()!="") { cmbBlock.Text = dr["BlockCode"].ToString(); } txtStreet1.Text = dr["Street1"].ToString(); txtStreet2.Text = dr["Street2"].ToString(); txtStreet3.Text = dr["Street3"].ToString(); txtCity.Text = dr["City"].ToString(); txtState.Text = dr["State"].ToString(); txtPost.Text = dr["PostalCode"].ToString(); txtCountry.Text = dr["Country"].ToString(); txtPhone1.Text = dr["Phone1"].ToString(); txtPhone2.Text = dr["Phone2"].ToString(); txtFax1.Text = dr["PhoneFax1"].ToString(); txtFax2.Text = dr["PhoneFax2"].ToString(); txtPhoneOther.Text = dr["PhoneOther"].ToString(); txtUrl.Text = dr["url"].ToString(); if(dr["DateJoined"]!=DBNull.Value) { dtJoined.Value = Convert.ToDateTime(dr["DateJoined"].ToString()); dtJoined.Checked = true; } else { dtJoined.Checked=false; } if(dr["DateEnded"]!=DBNull.Value) { dtEnded.Value = Convert.ToDateTime(dr["DateEnded"].ToString()); dtEnded.Checked = true; } else { dtEnded.Checked=false; } txtMintSt1.Text = dr["MinutesToStation1"].ToString(); txtClosestSt1.Text = dr["ClosestStation1"].ToString(); txtClosestLine1.Text = dr["Closestline1"].ToString(); txtMintSt2.Text = dr["MinutesToStation2"].ToString(); txtClosestSt2.Text = dr["ClosestStation2"].ToString(); txtClosestLine2.Text = dr["Closestline2"].ToString(); cmbStatus.SelectedIndex = Convert.ToInt16(dr["ContactStatus"].ToString()); } if(chkNoDept.Checked) txtCompName.Text = "No Department"; LoadContact(); } }