private void btnSave_Click(object sender, EventArgs e) { strFreebiz = ""; bool is4 = false; bool is8 = false; if (lkpEdtSalesPersonID.Text == "") { UI.ShowErrorMessage(this, "Please select Sales Person"); lkpEdtSalesPersonID.Focus(); DialogResult = DialogResult.None; return; } else employeeID = ACMS.Convert.ToInt32(lkpEdtSalesPersonID.EditValue); if (txtName1.Text.ToString().Length == 0 && txtContact1.Text.ToString().Length == 0 && txtName2.Text.ToString().Length == 0 && txtContact2.Text.ToString().Length == 0 && txtName3.Text.ToString().Length == 0 && txtContact3.Text.ToString().Length == 0 && txtName4.Text.ToString().Length == 0 && txtContact4.Text.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter 1st friend name & contact"); txtName1.Focus(); DialogResult = DialogResult.None; return; } if (txtName1.Text.ToString().Length != 0 || txtContact1.Text.ToString().Length != 0 || txtName2.Text.ToString().Length != 0 || txtContact2.Text.ToString().Length != 0 || txtName3.Text.ToString().Length != 0 || txtContact3.Text.ToString().Length != 0 || txtName4.Text.ToString().Length != 0 || txtContact4.Text.ToString().Length != 0) { if (txtName1.Text.ToString().Length == 0 && txtContact1.Text.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter 1st friend name & contact"); txtName1.Focus(); DialogResult = DialogResult.None; return; } else if (txtName2.Text.ToString().Length == 0 && txtContact2.Text.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter 2nd friend name & contact"); txtName2.Focus(); DialogResult = DialogResult.None; return; } else if (txtName3.Text.ToString().Length == 0 && txtContact3.Text.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter 3rd friend name & contact"); txtName3.Focus(); DialogResult = DialogResult.None; return; } else if (txtName4.Text.ToString().Length == 0 && txtContact4.Text.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter 4th friend name & contact"); txtName4.Focus(); DialogResult = DialogResult.None; return; } is4 = true; } if (txtName5.Text.ToString().Length != 0 || txtContact5.Text.ToString().Length != 0 || txtName6.Text.ToString().Length != 0 || txtContact6.Text.ToString().Length != 0 || txtName7.Text.ToString().Length != 0 || txtContact7.Text.ToString().Length != 0 || txtName8.Text.ToString().Length != 0 || txtContact8.Text.ToString().Length != 0) { if (txtName5.Text.ToString().Length == 0 && txtContact5.Text.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter 5th friend name & contact"); txtName5.Focus(); DialogResult = DialogResult.None; return; } else if (txtName6.Text.ToString().Length == 0 && txtContact6.Text.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter 6th friend name & contact"); txtName6.Focus(); DialogResult = DialogResult.None; return; } else if (txtName7.Text.ToString().Length == 0 && txtContact7.Text.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter 7th friend name & contact"); txtName7.Focus(); DialogResult = DialogResult.None; return; } else if (txtName8.Text.ToString().Length == 0 && txtContact8.Text.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter 8th friend name & contact"); txtName8.Focus(); DialogResult = DialogResult.None; return; } is4 = false; is8 = true; } if (ddl4Friends.Text.Length == 0 && is4) { UI.ShowErrorMessage(this, "Please select Reward for 4 friends!"); ddl4Friends.Focus(); DialogResult = DialogResult.None; return; } if (ddl8Friends.Text.Length == 0 && is8) { UI.ShowErrorMessage(this, "Please select Reward for 8 friends!"); ddl8Friends.Focus(); DialogResult = DialogResult.None; return; } if ((ddl4Friends.Text.Length != 0) && (ddl8Friends.Text.Length != 0)) { UI.ShowErrorMessage(this, "Please select only one Reward accordingly!"); DialogResult = DialogResult.None; return; } try { if (is4) { myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName1.Text, "", strTerminalBranchCode, "", cbGender1.Text, DateTime.Now, 13, "", txtContact1.Text, "",1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName2.Text, "", strTerminalBranchCode, "", cbGender2.Text, DateTime.Now, 13, "", txtContact2.Text, "", 1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName3.Text, "", strTerminalBranchCode, "", cbGender3.Text, DateTime.Now, 13, "", txtContact3.Text, "", 1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName4.Text, "", strTerminalBranchCode, "", cbGender4.Text, DateTime.Now, 13, "", txtContact4.Text, "", 1); TblRewards tr = new TblRewards(); ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); TblMember sqlMember = new TblMember(); TblRewardsTransaction sqlRewardsTransaction = new TblRewardsTransaction(); sqlRewardsTransaction.DRewardsPoints = Convert.ToInt16(ddl4Friends.EditValue.ToString()); sqlRewardsTransaction.DtDate = DateTime.Now; sqlRewardsTransaction.NEmployeeID = employeeID; sqlRewardsTransaction.NTypeID = 0; sqlRewardsTransaction.StrMembershipID = strMembershipID; sqlRewardsTransaction.StrReferenceNo = "4 Referral"; sqlRewardsTransaction.Insert(); } else if (is8) { myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName1.Text, "", strTerminalBranchCode, "", cbGender1.Text, DateTime.Now, 13, "", txtContact1.Text, "", 1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName2.Text, "", strTerminalBranchCode, "", cbGender2.Text, DateTime.Now, 13, "", txtContact2.Text, "", 1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName3.Text, "", strTerminalBranchCode, "", cbGender3.Text, DateTime.Now, 13, "", txtContact3.Text, "", 1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName4.Text, "", strTerminalBranchCode, "", cbGender4.Text, DateTime.Now, 13, "", txtContact4.Text, "", 1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName5.Text, "", strTerminalBranchCode, "", cbGender5.Text, DateTime.Now, 13, "", txtContact5.Text, "", 1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName6.Text, "", strTerminalBranchCode, "", cbGender6.Text, DateTime.Now, 13, "", txtContact6.Text, "", 1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName7.Text, "", strTerminalBranchCode, "", cbGender7.Text, DateTime.Now, 13, "", txtContact7.Text, "", 1); myContacts = new Contacts(); myContacts.NewContact(employeeID, txtName8.Text, "", strTerminalBranchCode, "", cbGender8.Text, DateTime.Now, 13, "", txtContact8.Text, "", 1); ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider(); TblMember sqlMember = new TblMember(); TblRewardsTransaction sqlRewardsTransaction = new TblRewardsTransaction(); sqlRewardsTransaction.DRewardsPoints = Convert.ToInt16(ddl8Friends.EditValue.ToString()); sqlRewardsTransaction.DtDate = DateTime.Now; sqlRewardsTransaction.NEmployeeID = employeeID; sqlRewardsTransaction.NTypeID = 0; sqlRewardsTransaction.StrMembershipID = strMembershipID; sqlRewardsTransaction.StrReferenceNo = "8 Referral"; sqlRewardsTransaction.Insert(); } MessageBox.Show("Intro Friends save successfully."); } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Close(); }