コード例 #1
0
ファイル: frmMain.cs プロジェクト: gregggdavis/schedww2
        private void Delete()
        {
            if (strMenuOption == "User...")
            {
                int Row = fUser.gvwUser.FocusedRowHandle;
                if (Row >= 0)
                {
                    int intUserID =
                        Convert.ToInt32(fUser.gvwUser.GetRowCellValue(fUser.gvwUser.FocusedRowHandle, fUser.gcolUserID).ToString());
                    int intContactID =
                        Convert.ToInt32(fUser.gvwUser.GetRowCellValue(fUser.gvwUser.FocusedRowHandle, fUser.gcolContactID).ToString());

                    if (Message.MsgDelete())
                    {
                        User objUser = new User();
                        objUser.UserID = intUserID;
                        objUser.ContactID = intContactID;
                        if (!objUser.DeleteData())
                        {
                            Message.MsgWarning("User cannot be deleted");
                            fUser.grdUser.Focus();
                            return;
                        }

                        fUser.LoadUser();
                        fUser.grdUser.Focus();
                        fUser.gvwUser.FocusedRowHandle = Row - 1;
                        if (fUser.gvwUser.RowCount > 0)
                        {
                            if (fUser.gvwUser.FocusedRowHandle < 0)
                            {
                                fUser.gvwUser.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            else if ((strMenuOption == "Contact...") || (strMenuOption == "Instructor...") || (strMenuOption == "Client..."))
            {
                string strtemp = "";
                int Row = fContact.gvwContact.FocusedRowHandle;
                if (Row >= 0)
                {
                    int intID =
                        Convert.ToInt32(
                            fContact.gvwContact.GetRowCellValue(fContact.gvwContact.FocusedRowHandle, fContact.gcolContactID).ToString());
                    strtemp = strMenuOption;
                    strtemp = strtemp.Replace("...", "");

                    if (Message.MsgDelete())
                    {
                        Contact objContact = new Contact();
                        objContact.ContactID = intID;
                        //objContact.DeleteData();
                        if (!objContact.DeleteData())
                        {
                            Message.MsgWarning(strtemp + " cannot be deleted");
                            fContact.grdContact.Focus();
                            return;
                        }

                        fContact.LoadContact(strtemp);
                        fContact.grdContact.Focus();
                        fContact.gvwContact.FocusedRowHandle = Row - 1;
                        if (fContact.gvwContact.RowCount > 0)
                        {
                            if (fContact.gvwContact.FocusedRowHandle < 0)
                            {
                                fContact.gvwContact.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            else if (strMenuOption == "Department...")
            {
                int Row = fDept.gvwDept.FocusedRowHandle;
                if (Row >= 0)
                {
                    int intDeptID =
                        Convert.ToInt32(fDept.gvwDept.GetRowCellValue(fDept.gvwDept.FocusedRowHandle, fDept.gColDeptID).ToString());
                    int intContactID =
                        Convert.ToInt32(fDept.gvwDept.GetRowCellValue(fDept.gvwDept.FocusedRowHandle, fDept.gColContactID).ToString());

                    if (Message.MsgDelete())
                    {
                        Department objDept = new Department();
                        objDept.DeptID = intDeptID;
                        objDept.ContactID = intContactID;
                        //objDept.DeleteData();
                        if (!objDept.DeleteData())
                        {
                            Message.MsgWarning("Department cannot be deleted");
                            fDept.grdDept.Focus();
                            return;
                        }

                        fDept.LoadDepartment();
                        fDept.grdDept.Focus();
                        fDept.gvwDept.FocusedRowHandle = Row - 1;
                        if (fDept.gvwDept.RowCount > 0)
                        {
                            if (fDept.gvwDept.FocusedRowHandle < 0)
                            {
                                fDept.gvwDept.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            else if (strMenuOption == "Program...")
            {
                int Row = fProgram.gvwProgram.FocusedRowHandle;
                if (Row >= 0)
                {
                    int intID =
                        Convert.ToInt32(
                            fProgram.gvwProgram.GetRowCellValue(fProgram.gvwProgram.FocusedRowHandle, fProgram.gcolProgID).ToString());

                    if (Message.MsgDelete())
                    {
                        Program objProg = new Program();
                        objProg.ProgramID = intID;
                        //objProg.DeleteData();
                        if (!objProg.DeleteData())
                        {
                            Message.MsgWarning("Program cannot be deleted");
                            fProgram.grdProgram.Focus();
                            return;
                        }

                        fProgram.LoadProgram();
                        fProgram.grdProgram.Focus();
                        fProgram.gvwProgram.FocusedRowHandle = Row - 1;
                        if (fProgram.gvwProgram.RowCount > 0)
                        {
                            if (fProgram.gvwProgram.FocusedRowHandle < 0)
                            {
                                fProgram.gvwProgram.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            else if (strMenuOption == "Class...")
            {
                int Row = fCourse.gvwCourse.FocusedRowHandle;
                if (Row >= 0)
                {
                    int intID =
                        Convert.ToInt32(
                            fCourse.gvwCourse.GetRowCellValue(fCourse.gvwCourse.FocusedRowHandle, fCourse.gcolCourseId).ToString());

                    if (Message.MsgDelete())
                    {
                        Course objCourse = new Course();
                        objCourse.CourseId = intID;
                        //objCourse.DeleteData();
                        if (!objCourse.DeleteData())
                        {
                            Message.MsgWarning("Class cannot be deleted");
                            fCourse.grdCourse.Focus();
                            return;
                        }

                        fCourse.LoadCourse();
                        fCourse.grdCourse.Focus();
                        fCourse.gvwCourse.FocusedRowHandle = Row - 1;
                        if (fCourse.gvwCourse.RowCount > 0)
                        {
                            if (fCourse.gvwCourse.FocusedRowHandle < 0)
                            {
                                fCourse.gvwCourse.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            else if (strMenuOption == "Event...")
            {
                int Row = fEvt.gvwEvent.FocusedRowHandle;
                bool IsRecur = false;

                if (Row >= 0)
                {
                    int intID =
                        Convert.ToInt32(fEvt.gvwEvent.GetRowCellValue(fEvt.gvwEvent.FocusedRowHandle, fEvt.gcolEventID).ToString());
                    int intCalID =
                        Convert.ToInt32(fEvt.gvwEvent.GetRowCellValue(fEvt.gvwEvent.FocusedRowHandle, fEvt.colCalendarEventID).ToString());
                    int CourseId = Convert.ToInt32(fEvt.gvwEvent.GetRowCellValue(fEvt.gvwEvent.FocusedRowHandle, fEvt.gcolCourseId).ToString());

                    if (fEvt.gvwEvent.GetRowCellValue(fEvt.gvwEvent.FocusedRowHandle, fEvt.gcolIsRecur).ToString() != "")
                        IsRecur = true;

                    if (IsRecur)
                    {
                        frmDeleteEvents frmDelEvt = new frmDeleteEvents(intID, intCalID);
                        if (frmDelEvt.ShowDialog() == DialogResult.OK)
                        {
                            fEvt.LoadEvent();
                            fEvt.grdEvent.Focus();
                            fEvt.gvwEvent.FocusedRowHandle = Row - 1;
                            if (fEvt.gvwEvent.RowCount > 0)
                            {
                                if (fEvt.gvwEvent.FocusedRowHandle < 0)
                                    fEvt.gvwEvent.FocusedRowHandle = 0;
                            }
                        }
                        frmDelEvt.Close();
                        frmDelEvt.Dispose();
                        frmDelEvt = null;
                    }
                    else
                    {
                        if (Message.MsgDelete())
                        {
                            string strMess = "";
                            Events evt = new Events();
                            evt.EventID = intID;
                            strMess = evt.CheckClassEvent();
                            if (strMess == "") strMess = evt.CheckProgramEvent();

                            if (strMess != "")
                            {
                                Message.MsgWarning("This Event is linked with" + strMess + ".\n\nEvent cannot be deleted.");
                                return;
                            }

                            //evt.DeleteData(true);
                            if (evt.EventType=="Extra Class")
                                evt.DeleteSingleCalendarEvent();
                            else
                                evt.DeleteTestEvent("Course", CourseId);

                            fEvt.LoadEvent();
                            fEvt.grdEvent.Focus();
                            fEvt.gvwEvent.FocusedRowHandle = Row - 1;
                            if (fEvt.gvwEvent.RowCount > 0)
                                if (fEvt.gvwEvent.FocusedRowHandle < 0)
                                    fEvt.gvwEvent.FocusedRowHandle = 0;
                        }
                    }
                }
            }
            else if (strMenuOption == "Calendar...")
            {
                if (fCalendar.schedulerControl1.SelectedAppointments.Count > 0)
                {
                    Appointment apt = fCalendar.schedulerControl1.SelectedAppointments[0];
                    bool IsRecur = false;

                    controller = new AppointmentFormController(fCalendar.schedulerControl1, apt);

                    int intCalID = Convert.ToInt32(controller.LabelId.ToString());
                    int intEventID = Common.GetID("select EventID from CalendarEvent where CalendarEventID=" + intCalID.ToString());
                    string strRecurrenceText =
                        Common.GetString("select RecurrenceText from Event where EventID=" + intEventID.ToString());

                    if (strRecurrenceText != "")
                        IsRecur = true;

                    if (IsRecur)
                    {
                        frmDeleteEvents frmDelEvt = new frmDeleteEvents(intEventID, intCalID);
                        if (frmDelEvt.ShowDialog() == DialogResult.OK)
                        {
                            fCalendar.LoadCalendar();
                        }
                        frmDelEvt.Close();
                        frmDelEvt.Dispose();
                        frmDelEvt = null;
                    }
                    else
                    {
                        if (Message.MsgDelete())
                        {
                            string strMess = "";
                            Events evt = new Events();
                            evt.EventID = intEventID;
                            strMess = evt.CheckClassEvent();
                            if (strMess == "") strMess = evt.CheckProgramEvent();

                            if (strMess != "")
                            {
                                Message.MsgWarning("This Event is linked with" + strMess + ".\n\nEvent cannot be deleted.");
                                return;
                            }

                            evt.DeleteData(true);
                            fCalendar.LoadCalendar();
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            if(BusinessLayer.Message.MsgDelete())
            {
                Scheduler.BusinessLayer.Department objDept=new Scheduler.BusinessLayer.Department();
                objDept.DeptID = _deptid;
                objDept.ContactID = intContactID;
                if(!objDept.DeleteData())
                {
                    BusinessLayer.Message.MsgWarning("Department cannot be deleted");
                    return;
                }
                else
                {
                    deleted=true;
                    btnDelete.Enabled=false;
                    this.Text = "Adding Department...";
                    _mode="Add";
                    _deptid=0;

                    foreach(Control c in tbpContact.Controls)
                    {
                        if(c.GetType().ToString() == "System.Windows.Forms.TextBox")
                        {
                            if(c.Tag==null) c.Text="";
                            else if(c.Tag.ToString()=="N") c.Text="0";
                        }
                        if(c.GetType().ToString() == "System.Windows.Forms.ComboBox")
                        {
                            c.Text="";
                        }
                        if(c.GetType().ToString() == "System.Windows.Forms.DateTimePicker")
                        {
                            DateTimePicker dp=c as DateTimePicker;
                            dp.Value = DateTime.Now;
                        }
                    }
                    foreach(Control c in tbpDeptInfo.Controls)
                    {
                        if(c.GetType().ToString() == "System.Windows.Forms.TextBox")
                        {
                            if(c.Tag==null) c.Text="";
                            else if(c.Tag.ToString()=="N") c.Text="0";
                        }
                        if(c.GetType().ToString() == "System.Windows.Forms.ComboBox")
                        {
                            c.Text="";
                        }
                        if(c.GetType().ToString() == "System.Windows.Forms.DateTimePicker")
                        {
                            DateTimePicker dp=c as DateTimePicker;
                            dp.Value = DateTime.Now;
                        }
                    }
                    this.DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
コード例 #3
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //Adding to Contact Table
            if(chkNoDept.Checked==false)
            {
                if(txtCompName.Text=="")
                {
                    tbcDepartment.SelectedIndex=0;
                    Scheduler.BusinessLayer.Message.MsgInformation("Enter Department Name");
                    txtCompName.Focus();
                    return;
                }
            }

            if(cmbClient.Text=="")
            {
                tbcDepartment.SelectedIndex=0;
                BusinessLayer.Message.MsgInformation("Enter Client");
                cmbClient.Focus();
                return;
            }

            bool boolSuccess;
            Scheduler.BusinessLayer.Contact objContact=null;

            objContact=new Scheduler.BusinessLayer.Contact();
            objContact.ContactID=0;

            objContact.LastName = "";
            objContact.LastNamePhonetic="";
            objContact.LastNameRomaji="";
            objContact.FirstName="";
            objContact.FirstNamePhonetic="";
            objContact.FirstNameRomaji="";
            //if(chkNoDept.Checked)
            //	objContact.CompanyName="No Department";
            //else
            objContact.NickName=txtNickName.Text;
            objContact.CompanyName=txtCompName.Text;
            objContact.CompanyNamePhonetic=txtCompPhonetic.Text;
            objContact.CompanyNameRomaji=txtCompRomaji.Text;
            objContact.TitleForName="";
            objContact.TitleForJob="";
            objContact.Street1=txtStreet1.Text;
            objContact.Street2=txtStreet2.Text;
            objContact.Street3=txtStreet3.Text;
            objContact.City=txtCity.Text;
            objContact.State=txtState.Text;
            objContact.PostalCode=txtPost.Text;
            objContact.Country=txtCountry.Text;
            objContact.ContactType=3;
            objContact.BlockCode=cmbBlock.Text;
            objContact.Email1="";
            objContact.Email2="";
            objContact.AccountRepLastName=txtAccLName.Text;
            objContact.AccountRepLastNamePhonetic=txtAccLPhonetic.Text;
            objContact.AccountRepLastNameRomaji=txtAccLRomaji1.Text;
            objContact.AccountRepFirstName=txtAccFirstName.Text;
            objContact.AccountRepFirstNamePhonetic=txtAccFirstPhonetic.Text;
            objContact.AccountRepFirstNameRomaji=txtAccFirstRomaji.Text;
            objContact.Phone1=txtPhone1.Text;
            objContact.Phone2=txtPhone2.Text;
            objContact.PhoneMobile1="";
            objContact.PhoneMobile2="";
            objContact.PhoneBusiness1="";
            objContact.PhoneBusiness2="";
            objContact.PhoneFax1=txtFax1.Text;
            objContact.PhoneFax2=txtFax2.Text;
            objContact.PhoneOther=txtPhoneOther.Text;
            objContact.Url=txtUrl.Text;

            objContact.DateBirth=Convert.ToDateTime(null);
            objContact.DateJoined=Convert.ToDateTime(null);
            objContact.DateEnded=Convert.ToDateTime(null);

            //objContact.TimeStatus=.Text;
            objContact.Nationality="";
            objContact.Married=0;
            objContact.NumberDependents=0;

            objContact.VisaStatus="";
            objContact.VisaFromDate=Convert.ToDateTime(null);
            objContact.VisaUntilDate=Convert.ToDateTime(null);

            objContact.ClosestStation1=txtClosestSt1.Text;
            objContact.ClosestLine1=txtClosestLine1.Text;
            Int16 minToStation = 0;
            if (txtMintSt1.Text != "")
            {
                Int16.TryParse(txtMintSt1.Text, out minToStation);
            }
            Int16 minToStation2 = 0;
            if (txtMintSt2.Text != "")
            {
                Int16.TryParse(txtMintSt2.Text, out minToStation2);
            }
            objContact.MinutesToStation1=minToStation;
            objContact.MinutesToStation2 = minToStation2;
            objContact.ClosestStation2=txtClosestSt2.Text;
            objContact.ClosestLine2=txtClosestLine2.Text;

            objContact.ContactStatus=cmbStatus.SelectedIndex;

            int intCID=0;
            intCID = Common.GetCompanyID(
                "Select ContactID From Contact " +
                "Where (CompanyName =@CompanyName OR NickName=@CompanyName) ", cmbClient.Text
                );

            if ((_mode == "Add") || (_mode == "AddClone") || (_mode == ""))
            {
                if(objContact.Exists(txtCompName.Text, intCID, 3))
                {
                    Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Department Name not allowed");
                    txtCompName.Focus();
                    return;
                }
                if(txtNickName.Text!="")
                {
                    if(objContact.NickNameExists(txtNickName.Text, intCID, 3))
                    {
                        Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Abbreviated Name not allowed");
                        txtNickName.Focus();
                        return;
                    }
                }
                boolSuccess = objContact.InsertData();
            }
            else
            {
                if((txtCompName.Tag.ToString()!=txtCompName.Text) || (cmbClient.Tag.ToString()!=cmbClient.Text))
                {
                    if(objContact.Exists(txtCompName.Text, intCID, 3))
                    {
                        Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Department Name not allowed");
                        txtCompName.Focus();
                        return;
                    }
                }
                if(txtNickName.Text!="")
                {
                    if((txtNickName.Tag.ToString()!=txtNickName.Text) || (cmbClient.Tag.ToString()!=cmbClient.Text))
                    {
                        if(objContact.NickNameExists(txtNickName.Text, intCID, 3))
                        {
                            Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Abbreviated Name not allowed");
                            txtNickName.Focus();
                            return;
                        }
                    }
                }
                objContact.ContactID=_contactid;
                boolSuccess = objContact.UpdateData();
            }
            if(!boolSuccess)
            {
                if (_mode == "Add")
                    Scheduler.BusinessLayer.Message.ShowException("Adding Contact record.", objContact.Message);
                else if (_mode == "AddClone")
                    Scheduler.BusinessLayer.Message.ShowException("Cloning Contact record.", objContact.Message);
                else
                    Scheduler.BusinessLayer.Message.ShowException("Updating Contact record.", objContact.Message);
                return;
            }

            //Getting ContactID
            _contactid = objContact.ContactID;

            //Adding to Department Table

            /*if(txtDeptName.Text=="")
            {
                BusinessLayer.Message.MsgInformation("Enter Department");
                txtDeptName.Focus();
                return;
            }
            if(cmbContact.Text=="")
            {
                BusinessLayer.Message.MsgInformation("Enter Contact");
                cmbContact.Focus();
                return;
            }
            if(cmbClient.Text=="")
            {
                BusinessLayer.Message.MsgInformation("Enter Client");
                cmbClient.Focus();
                return;
            }*/

            Department objDept=new Department();
            //objDept.DeptName = txtDeptName.Text;

            if(cmbClient.Text.Trim()=="")
            {
                objDept.ClientID=0;
            }
            else
            {
                objDept.ClientID = Common.GetCompanyID(
                    "Select ContactID From Contact " +
                    "Where (CompanyName =@CompanyName OR NickName=@CompanyName) ", cmbClient.Text
                    );
            }

            /*if(cmbContact.Text.Trim()=="")
            {
                objDept.ContactID=0;
            }
            else
            {
                string[] arr = cmbContact.Text.Split(new char[]{','});
                if(arr.Length==1)
                {
                    objDept.ContactID = Common.GetID(
                        "Select ContactID From Contact " +
                        "Where LastName ='" + arr[0].Trim() + "' "
                        );
                }
                else
                {
                    objDept.ContactID = Common.GetID(
                        "Select ContactID From Contact " +
                        "Where LastName ='" + arr[0].Trim() + "' and FirstName = '" + arr[1].Trim() + "' "
                        );
                }
            }*/

            objDept.ContactID = _contactid;
            objDept.StatusID = cmbStatus.SelectedIndex;

            if ((_mode == "Add") || (_mode == "AddClone") || (_mode == ""))
            {
                if(objDept.InsertData()==false)
                {
                    BusinessLayer.Message.ShowException("Adding Department", objDept.Message);
                }
                else
                {
                    if(intRandomNo>0)
                    {
                        //replace the randomno with deptid
                        objContact.RefID=objDept.DeptID;
                        objContact.UpdateRefID(intRandomNo);
                    }
                }
            }
            else
            {
                objDept.DeptID=_deptid;
                if(objDept.UpdateData()==false)
                {
                    BusinessLayer.Message.ShowException("Editing Department", objDept.Message);
                }
            }

            this.DialogResult = DialogResult.OK;
            Close();
        }
コード例 #4
0
        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();
            }
        }