private void btnDel_Click(object sender, System.EventArgs e)
        {
            BusinessLayer.Contact objContact=new BusinessLayer.Contact();
            objContact.ContactType=5;

            if(gvwContact.FocusedRowHandle<0) return;
            int _contid=0;
            _contid=Convert.ToInt32(gvwContact.GetRowCellValue(gvwContact.FocusedRowHandle, gcolContactID).ToString());
            objContact.ContactID =_contid;
            objContact.DeleteData();
            //Delete the contacts from the Program Table as well
            objContact.DeleteContactFromProgram();

            LoadData();
        }
        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();
        }
Beispiel #3
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            bool boolSuccess;

            if(txtCompName.Text=="")
            {
                Scheduler.BusinessLayer.Message.MsgInformation("Enter Company Name");
                txtCompName.Focus();
                return;
            }

            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="";
            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=2;
            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);

            if(dtJoined.Checked)
                objContact.DateJoined=dtJoined.Value;
            else
                objContact.DateJoined=Convert.ToDateTime(null);

            if(dtEnded.Checked)
                objContact.DateEnded=dtEnded.Value;
            else
                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;
            objContact.MinutesToStation1=Convert.ToInt16(txtMintSt1.Text);
            objContact.ClosestStation2=txtClosestSt2.Text;
            objContact.ClosestLine2=txtClosestLine2.Text;
            objContact.MinutesToStation2=Convert.ToInt16(txtMintSt2.Text);
            objContact.ContactStatus=cmbStatus.SelectedIndex;

            if ((_mode == "Add") || (_mode == "AddClone") || (_mode == ""))
            {
                if(objContact.Exists(txtCompName.Text, 2))
                {
                    Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Client Name not allowed");
                    txtCompName.Focus();
                    return;
                }
                if(txtNickName.Text!="")
                {
                    if(objContact.NickNameExists(txtNickName.Text, 2))
                    {
                        Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Abbreviated Name not allowed");
                        txtNickName.Focus();
                        return;
                    }
                }
                boolSuccess = objContact.InsertData();
                if(boolSuccess)
                {
                    if(intRandomNo>0)
                    {
                        //replace the randomno with deptid
                        objContact.RefID=objContact.ContactID;
                        objContact.UpdateRefID(intRandomNo);
                    }
                }
            }
            else
            {
                if(txtCompName.Text!=txtCompName.Tag.ToString())
                {
                    if(objContact.Exists(txtCompName.Text, 2))
                    {
                        Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Client Name not allowed");
                        txtCompName.Focus();
                        return;
                    }
                }
                if(txtNickName.Text!="")
                {
                    if(txtNickName.Text!=txtNickName.Tag.ToString())
                    {
                        if(objContact.NickNameExists(txtNickName.Text, 2))
                        {
                            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;
            }
            this.DialogResult = DialogResult.OK;
            Close();
        }
 private void LoadContact()
 {
     if (_mode != "AddClone")
     {
         BusinessLayer.Contact objContact = new BusinessLayer.Contact();
         objContact.ContactType = 5;
         objContact.RefID = _deptid;
         if (_deptid <= 0) objContact.RefID = intRandomNo;
         DataTable dtbl = objContact.LoadData("DepartmentContact");
         grdContact.DataSource = (DataTable)dtbl;
     }
 }
Beispiel #5
0
        public void LoadData()
        {
            if (_mode == "Edit" || _mode == "AddClone")
            {
                if (_mode == "Edit")
                {
                    btnDelete.Enabled = true;
                    this.Text = "Editing Client...";
                }
                else
                {
                    btnDelete.Enabled = false;
                    this.Text = "Adding Client Clone...";
                }

                Scheduler.BusinessLayer.Contact objContact=new Scheduler.BusinessLayer.Contact();
                objContact.ContactID = _contactid;
                objContact.LoadData("Contact");

                foreach(DataRow dr in objContact.dtblContacts.Rows)
                {
                    txtCompName.Text = dr["CompanyName"].ToString();
                    txtCompName.Tag = txtCompName.Text;
                    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"]!=System.DBNull.Value)
                    {
                        dtJoined.Value = Convert.ToDateTime(dr["DateJoined"].ToString());
                        dtJoined.Checked = true;
                    }
                    else
                    {
                        dtJoined.Checked=false;
                    }

                    if(dr["DateEnded"]!=System.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());
                }
            }
            else
            {
                btnDelete.Enabled=true;
                this.Text = "Adding Client...";

                txtCompName.Text = String.Empty;
                txtCompName.Tag = String.Empty;

                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.Checked = dtEnded.Checked = true;
                dtJoined.Value = dtEnded.Value = DateTime.Now;

                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;

            }
            LoadContact();
        }
Beispiel #6
0
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            if(BusinessLayer.Message.MsgDelete())
            {
                Scheduler.BusinessLayer.Contact objContact=new Scheduler.BusinessLayer.Contact();
                objContact.ContactID = _contactid;
                if(!objContact.DeleteData())
                {
                    BusinessLayer.Message.MsgWarning("Client cannot be deleted");
                    return;
                }
                else
                {
                    deleted=true;
                    btnDelete.Enabled=false;
                    this.Text = "Adding Client...";
                    _mode="Add";
                    _contactid=0;

                    foreach(Control c in tbpAddress.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 tbpClientInfo.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();
                }
            }
        }
Beispiel #7
0
        public void LoadData()
        {
            if(_mode=="Edit" || _mode=="AddClone")
            {
                if (_mode == "Edit")
                    this.Text = "Editing Course...";
                else
                    this.Text = "Adding Contact Clone...";

                Scheduler.BusinessLayer.Contact objContact=new Scheduler.BusinessLayer.Contact();
                objContact.ContactID = _contactid;
                objContact.LoadData("Contact");

                foreach(DataRow dr in objContact.dtblContacts.Rows)
                {
                    cmbType.SelectedIndex = Convert.ToInt16(dr["ContactType"].ToString());

                    txtLName.Text = dr["LastName"].ToString();
                    txtLNamePhonetic.Text = dr["LastNamePhonetic"].ToString();
                    txtLNameRomaji.Text = dr["LastNameRomaji"].ToString();
                    txtFName.Text = dr["FirstName"].ToString();
                    if (_mode == "AddClone") txtFName.Text = "Copy of " + txtFName.Text;
                    txtFNamePhonetic.Text = dr["FirstNamePhonetic"].ToString();
                    txtFNameRomaji.Text = dr["FirstNameRomaji"].ToString();

                    txtCompName.Text = dr["CompanyName"].ToString();
                    txtCompPhonetic.Text = dr["CompanyNamePhonetic"].ToString();
                    txtCompRomaji.Text = dr["CompanyNameRomaji"].ToString();

                    txtContactName1.Text = dr["ContactlastName1"].ToString();
                    txtContactPhonetic1.Text = dr["ContactlastNamePhonetic1"].ToString();
                    txtContactRomaji1.Text = dr["ContactLastNameRomaji1"].ToString();
                    txtContactName2.Text = dr["ContactLastName2"].ToString();
                    txtContactPhonetic2.Text = dr["ContactLastNamePhonetic2"].ToString();
                    txtContactRomaji2.Text = dr["ContactLastNameRomaji2"].ToString();

                    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();

                    cmbTitle.Text = dr["TitleForname"].ToString();
                    txtTitleJob.Text = dr["TitleForJob"].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();

                    txtEmail1.Text = dr["Email1"].ToString();
                    txtEmail2.Text = dr["EMail2"].ToString();

                    txtPhone1.Text = dr["Phone1"].ToString();
                    txtPhone2.Text = dr["Phone2"].ToString();
                    txtMobile1.Text = dr["PhoneMobile1"].ToString();
                    txtMobile2.Text = dr["PhoneMobile2"].ToString();
                    txtPhone3.Text = dr["PhoneBusiness1"].ToString();
                    txtPhone4.Text = dr["PhoneBusiness2"].ToString();
                    txtFax1.Text = dr["PhoneFax1"].ToString();
                    txtFax2.Text = dr["PhoneFax2"].ToString();
                    txtPhoneOther.Text = dr["PhoneOther"].ToString();
                    txtUrl.Text = dr["url"].ToString();

                    if(dr["DateBirth"]!=System.DBNull.Value)
                        dtDOB.Value = Convert.ToDateTime(dr["DateBirth"].ToString());
                    else
                        dtDOB.Checked=false;

                    if(dr["DateJoined"]!=System.DBNull.Value)
                        dtJoined.Value = Convert.ToDateTime(dr["DateJoined"].ToString());
                    else
                        dtJoined.Checked=false;

                    if(dr["DateEnded"]!=System.DBNull.Value)
                        dtEnded.Value = Convert.ToDateTime(dr["DateEnded"].ToString());
                    else
                        dtEnded.Checked=false;

                    txtNationality.Text = dr["Nationality"].ToString();
                    cmbMarried.SelectedIndex = Convert.ToInt16(dr["Married"].ToString());
                    txtNoDependent.Text = dr["NumberDependents"].ToString();

                    txtVisaStatus.Text = dr["VisaStatus"].ToString();

                    if(dr["VisaFromDate"]!=System.DBNull.Value)
                        dtVisaFrom.Value = Convert.ToDateTime(dr["VisaFromDate"].ToString());
                    else
                        dtVisaFrom.Checked=false;

                    if(dr["VisaUntilDate"]!=System.DBNull.Value)
                        dtVisaTo.Value = Convert.ToDateTime(dr["VisaUntilDate"].ToString());
                    else
                        dtVisaTo.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());
                }
            }
            else
            {
                this.Text = "Adding Contact...";
            }
        }
        private void LoadData()
        {
            BusinessLayer.Contact objContact=new BusinessLayer.Contact();
            objContact.ContactID=_id;
            objContact.RefID=0;
            DataTable dtbl = objContact.LoadData(_contacttype);
            foreach(DataRow dr in dtbl.Rows)
            {
                txtFName.Text = dr["FirstName"].ToString();
                txtFNamePhonetic.Text = dr["FirstNamePhonetic"].ToString();
                txtFNameRomaji.Text = dr["FirstNameRomaji"].ToString();

                txtLName.Text = dr["LastName"].ToString();
                txtLNamePhonetic.Text = dr["LastNamePhonetic"].ToString();
                txtLNameRomaji.Text = dr["LastNameRomaji"].ToString();
                txtFax.Text = dr["PhoneFax1"].ToString();
                txtFName.Tag = txtFName.Text;
                txtLName.Tag = txtLName.Text;

                txtEmail.Text = dr["Email1"].ToString();
                txtPhone.Text = dr["Phone1"].ToString();
                txtMobile.Text = dr["PhoneMobile1"].ToString();

                if(dr["ContactStatus"]==null)cmbStatus.SelectedIndex=0;
                cmbStatus.SelectedIndex = Convert.ToInt16(dr["ContactStatus"].ToString());

                break;
            }
        }
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //if(txtFName.Text=="")
            //{
            //	BusinessLayer.Message.MsgInformation("Enter Contact First Name");
            //	txtFName.Focus();
            //	return;
            //}
            if(txtLName.Text=="")
            {
                BusinessLayer.Message.MsgInformation("Enter Contact Last Name");
                txtLName.Focus();
                return;
            }
            if(cmbStatus.SelectedIndex==-1)
            {
                BusinessLayer.Message.MsgInformation("Enter Contact Status");
                cmbStatus.Focus();
                return;
            }

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

            objContact=new Scheduler.BusinessLayer.Contact();
            objContact.ContactID=0;
            if(ContactType=="DepartmentContact")
                objContact.ContactType=5;
            else
                objContact.ContactType=4;

            if(_mode=="Edit")
            {
                if((txtFName.Text!=txtFName.Tag.ToString()) || (txtLName.Text!=txtLName.Tag.ToString()))
                {
                    if(objContact.ContactExists(_refid, txtFName.Text, txtLName.Text))
                    {
                        Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Contact Name not allowed");
                        txtFName.Focus();
                        return;
                    }
                }
            }
            else
            {
                if(objContact.ContactExists(_refid, txtFName.Text, txtLName.Text))
                {
                    Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Contact Name not allowed");
                    txtFName.Focus();
                    return;
                }
            }

            objContact.LastName = txtLName.Text;
            objContact.LastNamePhonetic=txtLNamePhonetic.Text;
            objContact.LastNameRomaji=txtLNameRomaji.Text;
            objContact.FirstName=txtFName.Text;
            objContact.FirstNamePhonetic=txtFNamePhonetic.Text;
            objContact.FirstNameRomaji=txtFNameRomaji.Text;
            objContact.CompanyName="";
            objContact.CompanyNamePhonetic="";
            objContact.CompanyNameRomaji="";
            objContact.TitleForName="";
            objContact.TitleForJob="";
            objContact.Street1="";
            objContact.Street2="";
            objContact.Street3="";
            objContact.City="";
            objContact.State="";
            objContact.PostalCode="";
            objContact.Country="";
            objContact.BlockCode="";
            objContact.Email1=txtEmail.Text;
            objContact.Email2="";
            objContact.AccountRepLastName="";
            objContact.AccountRepLastNamePhonetic="";
            objContact.AccountRepLastNameRomaji="";
            objContact.AccountRepFirstName="";
            objContact.AccountRepFirstNamePhonetic="";
            objContact.AccountRepFirstNameRomaji="";
            objContact.Phone1=txtPhone.Text;
            objContact.Phone2="";
            objContact.PhoneMobile1=txtMobile.Text;
            objContact.PhoneMobile2="";
            objContact.PhoneBusiness1="";
            objContact.PhoneBusiness2="";
            objContact.PhoneFax1=txtFax.Text;
            objContact.PhoneFax2="";
            objContact.PhoneOther="";
            objContact.Url="";

            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="";
            objContact.ClosestLine1="";
            objContact.MinutesToStation1=0;
            objContact.ClosestStation2="";
            objContact.ClosestLine2="";
            objContact.MinutesToStation2=0;
            objContact.ContactStatus=cmbStatus.SelectedIndex;

            objContact.RefID=_refid;

            if((_mode=="Add") || (_mode==""))
            {
                /*if(chkNoDept.Checked==false)
                {
                    if(objContact.Exists(txtCompName.Text, intCID, 3))
                    {
                        Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Department Name not allowed");
                        txtCompName.Focus();
                        return;
                    }
                }*/
                boolSuccess = objContact.InsertData();
            }
            else
            {
                /*if(chkNoDept.Checked==false)
                {
                    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;
                        }
                    }
                }*/
                objContact.ContactID=_id;
                boolSuccess = objContact.UpdateData();
            }
            if(!boolSuccess)
            {
                if(_mode=="Add")
                    Scheduler.BusinessLayer.Message.ShowException("Adding Contact record.", objContact.Message);
                else
                    Scheduler.BusinessLayer.Message.ShowException("Updating Contact record.", objContact.Message);
                return;
            }

            Close();
            this.DialogResult=DialogResult.OK;
        }
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            bool boolSuccess;

            if(txtFName.Text=="")
            {
                Scheduler.BusinessLayer.Message.MsgInformation("Enter First Name");
                txtFName.Focus();
                return;
            }
            if(txtLName.Text=="")
            {
                Scheduler.BusinessLayer.Message.MsgInformation("Enter Last Name");
                txtLName.Focus();
                return;
            }

            Scheduler.BusinessLayer.Contact objContact=null;

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

            objContact.LastName = txtLName.Text;
            objContact.LastNamePhonetic=txtLNamePhonetic.Text;
            objContact.LastNameRomaji=txtLNameRomaji.Text;
            objContact.FirstName=txtFName.Text;
            objContact.FirstNamePhonetic=txtFNamePhonetic.Text;
            objContact.FirstNameRomaji=txtFNameRomaji.Text;
            objContact.CompanyName=txtCompName.Text;
            objContact.CompanyNamePhonetic=txtCompPhonetic.Text;
            objContact.CompanyNameRomaji=txtCompRomaji.Text;
            objContact.TitleForName=cmbTitle.Text;
            objContact.TitleForJob=txtTitleJob.Text;
            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=1;
            objContact.BlockCode=cmbBlock.Text;
            objContact.Email1=txtEmail1.Text;
            objContact.Email2=txtEmail2.Text;
            objContact.AccountRepLastName="";
            objContact.AccountRepLastNamePhonetic="";
            objContact.AccountRepLastNameRomaji="";
            objContact.AccountRepFirstName="";
            objContact.AccountRepFirstNamePhonetic="";
            objContact.AccountRepFirstNameRomaji="";
            objContact.Phone1=txtPhone1.Text;
            objContact.Phone2=txtPhone2.Text;
            objContact.PhoneMobile1=txtMobile1.Text;
            objContact.PhoneMobile2=txtMobile2.Text;
            objContact.PhoneBusiness1=txtPhone3.Text;
            objContact.PhoneBusiness2=txtPhone4.Text;
            objContact.PhoneFax1=txtFax1.Text;
            objContact.PhoneFax2=txtFax2.Text;
            objContact.PhoneOther=txtPhoneOther.Text;
            objContact.Url=txtUrl.Text;
            objContact.BaseRate = Convert.ToDecimal(spinBaseRate.Text);
            if(dtDOB.Checked)
                objContact.DateBirth=dtDOB.Value;
            else
                objContact.DateBirth=Convert.ToDateTime(null);

            if(dtJoined.Checked)
                objContact.DateJoined=dtJoined.Value;
            else
                objContact.DateJoined=Convert.ToDateTime(null);

            if(dtEnded.Checked)
                objContact.DateEnded=dtEnded.Value;
            else
                objContact.DateEnded=Convert.ToDateTime(null);

            objContact.TimeStatus= cmbEmpStatus.Text;
            objContact.Nationality=txtNationality.Text;
            objContact.Married=cmbMarried.SelectedIndex;
            objContact.NumberDependents=Convert.ToInt16(txtNoDependent.Text);

            objContact.VisaStatus=txtVisaStatus.Text;
            if(dtVisaTo.Checked)
                objContact.VisaFromDate=dtVisaFrom.Value;
            else
                objContact.VisaFromDate=Convert.ToDateTime(null);

            if(dtVisaTo.Checked)
                objContact.VisaUntilDate=dtVisaTo.Value;
            else
                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.ClosestStation2=txtClosestSt2.Text;
            objContact.ClosestLine2=txtClosestLine2.Text;
            objContact.MinutesToStation2=minToStation2;
            objContact.ContactStatus=cmbStatus.SelectedIndex;

            objContact.ContactID=_contactid;
            if(objContact.Exists(txtFName.Text, txtLName.Text, 1))
            {
                Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Instructor Name not allowed");
                txtLName.Focus();
                return;
            }

            if ((_mode == "Add") || (_mode == "AddClone") || (_mode == ""))
            {
                boolSuccess = objContact.InsertData();
            }
            else
            {
                objContact.ContactID=_contactid;
                boolSuccess = objContact.UpdateData();
            }
            if(!boolSuccess)
            {
                if (_mode == "Add")
                    Scheduler.BusinessLayer.Message.ShowException("Adding Instructor record.", objContact.Message);
                else if (_mode == "AddClone")
                    Scheduler.BusinessLayer.Message.ShowException("Cloning Instructor record.", objContact.Message);
                else
                    Scheduler.BusinessLayer.Message.ShowException("Updating Instructor record.", objContact.Message);
                return;
            }

            this.DialogResult = DialogResult.OK;
            Close();
        }
Beispiel #11
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //if(txtFName.Text=="")
            //{
            //	BusinessLayer.Message.MsgInformation("Enter Contact First Name");
            //	txtFName.Focus();
            //	return;
            //}
            if (txtLName.Text == "")
            {
                BusinessLayer.Message.MsgInformation("Enter Contact Last Name");
                txtLName.Focus();
                return;
            }
            if (cmbStatus.SelectedIndex == -1)
            {
                BusinessLayer.Message.MsgInformation("Enter Contact Status");
                cmbStatus.Focus();
                return;
            }


            bool boolSuccess = false;

            Scheduler.BusinessLayer.Contact objContact = null;

            objContact           = new Scheduler.BusinessLayer.Contact();
            objContact.ContactID = 0;
            if (ContactType == "DepartmentContact")
            {
                objContact.ContactType = 5;
            }
            else
            {
                objContact.ContactType = 4;
            }

            if (_mode == "Edit")
            {
                if ((txtFName.Text != txtFName.Tag.ToString()) || (txtLName.Text != txtLName.Tag.ToString()))
                {
                    if (objContact.ContactExists(_refid, txtFName.Text, txtLName.Text))
                    {
                        Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Contact Name not allowed");
                        txtFName.Focus();
                        return;
                    }
                }
            }
            else
            {
                if (objContact.ContactExists(_refid, txtFName.Text, txtLName.Text))
                {
                    Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Contact Name not allowed");
                    txtFName.Focus();
                    return;
                }
            }

            objContact.LastName            = txtLName.Text;
            objContact.LastNamePhonetic    = txtLNamePhonetic.Text;
            objContact.LastNameRomaji      = txtLNameRomaji.Text;
            objContact.FirstName           = txtFName.Text;
            objContact.FirstNamePhonetic   = txtFNamePhonetic.Text;
            objContact.FirstNameRomaji     = txtFNameRomaji.Text;
            objContact.CompanyName         = "";
            objContact.CompanyNamePhonetic = "";
            objContact.CompanyNameRomaji   = "";
            objContact.TitleForName        = "";
            objContact.TitleForJob         = "";
            objContact.Street1             = "";
            objContact.Street2             = "";
            objContact.Street3             = "";
            objContact.City                        = "";
            objContact.State                       = "";
            objContact.PostalCode                  = "";
            objContact.Country                     = "";
            objContact.BlockCode                   = "";
            objContact.Email1                      = txtEmail.Text;
            objContact.Email2                      = "";
            objContact.AccountRepLastName          = "";
            objContact.AccountRepLastNamePhonetic  = "";
            objContact.AccountRepLastNameRomaji    = "";
            objContact.AccountRepFirstName         = "";
            objContact.AccountRepFirstNamePhonetic = "";
            objContact.AccountRepFirstNameRomaji   = "";
            objContact.Phone1                      = txtPhone.Text;
            objContact.Phone2                      = "";
            objContact.PhoneMobile1                = txtMobile.Text;
            objContact.PhoneMobile2                = "";
            objContact.PhoneBusiness1              = "";
            objContact.PhoneBusiness2              = "";
            objContact.PhoneFax1                   = txtFax.Text;
            objContact.PhoneFax2                   = "";
            objContact.PhoneOther                  = "";
            objContact.Url = "";

            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   = "";
            objContact.ClosestLine1      = "";
            objContact.MinutesToStation1 = 0;
            objContact.ClosestStation2   = "";
            objContact.ClosestLine2      = "";
            objContact.MinutesToStation2 = 0;
            objContact.ContactStatus     = cmbStatus.SelectedIndex;

            objContact.RefID = _refid;

            if ((_mode == "Add") || (_mode == ""))
            {
                /*if(chkNoDept.Checked==false)
                 * {
                 *      if(objContact.Exists(txtCompName.Text, intCID, 3))
                 *      {
                 *              Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Department Name not allowed");
                 *              txtCompName.Focus();
                 *              return;
                 *      }
                 * }*/
                boolSuccess = objContact.InsertData();
            }
            else
            {
                /*if(chkNoDept.Checked==false)
                 * {
                 *      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;
                 *              }
                 *      }
                 * }*/
                objContact.ContactID = _id;
                boolSuccess          = objContact.UpdateData();
            }
            if (!boolSuccess)
            {
                if (_mode == "Add")
                {
                    Scheduler.BusinessLayer.Message.ShowException("Adding Contact record.", objContact.Message);
                }
                else
                {
                    Scheduler.BusinessLayer.Message.ShowException("Updating Contact record.", objContact.Message);
                }
                return;
            }

            Close();
            this.DialogResult = DialogResult.OK;
        }