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