コード例 #1
0
ファイル: Appointment.cs プロジェクト: kimykunjun/test
        public bool CloseAppointment(int nAppointmentID)
        {
            TblAppointment myAppointment = new TblAppointment();
            myAppointment.NAppointmentId = nAppointmentID;
            myAppointment.SelectOne();
            myAppointment.NStatus = 2;
            myAppointment.Update();

            TblContacts myContact = new TblContacts();
            myContact.UpdateLeadStatus(Convert.ToInt32(myAppointment.NContactId.Value), 0);
            return true;
        }
コード例 #2
0
ファイル: frmContacts.cs プロジェクト: kimykunjun/test
        protected void SendConfirmation(string nContactId, string strContactName, string strEmail, ref TblContacts myContacts)
        {
            int nEdmId = 122;
            string tmp_strEncryptionKey = "";
            string tmp_strSubject = "";
            string tmp_strContent = "";
            string tmp_strSender = "";
            Random rnd = new Random();

            DateTime dtToday = DateTime.Today;
            string dtExpiryDate = String.Format("{0:MMM d, yyyy}", dtToday.AddMonths(1));

            //Blast the email consent to the leads if email is not null
            if (strEmail.Trim() != "" && IsEmailValid(strEmail))
            {
                DataTable dtEdmContent = new DataTable();

                dtEdmContent = myContacts.GetLeadConfirmationEmail();

                if (dtEdmContent.Rows.Count > 0)
                {
                    foreach (DataRow rs in dtEdmContent.Rows)
                    {
                        tmp_strSender = rs["strSender"].ToString().Trim();
                        tmp_strSubject = rs["strSubject"].ToString().Trim();
                        tmp_strContent = rs["strContent"].ToString().Trim();
                    }
                }

                dtEdmContent.Dispose();
                //nEdmId = myContacts.CreateNewEdm(tmp_strSender, tmp_strSubject, tmp_strContent, 1, 9, "L"); //Insert Into DB

                string tmp_strMembershipID = nContactId.ToString();
                string tmp_strMemberName = strContactName;
                //Generate random order number 1-5
                int tmp_nOrder = GetRandomOrderNo(rnd);
                string tmp_strDate = GetToday();

                //Generate Encryption Key, status = 0
                tmp_strEncryptionKey = GetEncryptionKey(nEdmId, tmp_strMembershipID, strEmail.Trim(), tmp_strDate);

                //Need to check if email has been sent - from logs
                if (!IsDuplicatedSubmission(tmp_strMembershipID,
                                                    strEmail.Trim(),
                                                    nEdmId,
                                                    tmp_strEncryptionKey))
                {
                    //Send Email
                    SendEDM(nContactId, strContactName.ToUpper(), dtExpiryDate, strEmail,
                                tmp_strSender, tmp_strSubject, tmp_strContent, nEdmId.ToString(),
                                tmp_strEncryptionKey);

                    InsertEmailSendingLog(strEmail.Trim(), nEdmId,
                                                    tmp_strMembershipID, tmp_strMemberName,
                                                    tmp_strDate, tmp_strEncryptionKey,
                                                    "L");
                }

            }
        }
コード例 #3
0
ファイル: frmContacts.cs プロジェクト: kimykunjun/test
        private void sbtnSave_Click(object sender, System.EventArgs e)
        {
            //bool isSuccess = false; // return value
            int myContactId = 0;
            string strContactName = txtContactPerson.Text.ToString().Trim();
            string strNRICFIN = txtNRICFIN.Text.ToString().Trim().ToUpper();
            string strMobileNo = txtMobileNo.Text.ToString().Trim();
            string strEmail = txtEmail.Text.ToString().Trim();
            string strGender = "";
            Nullable<DateTime> dtDOB = null;  //DateTime?
            int nMediaSourceID = -1;
            string strBranchCode = txtBranchCode.Text.ToString().Trim();
            string strRemarks = rtxtRemarks.Text.ToString().Trim();
            bool fPhoneCall = false;
            bool fSMS = false;
            bool fEmail = false;
            int fDNC = -1;
            string nEntryBy = nEmployeeID.ToString();
            int nStatus;

            ACMSLogic.Staff.Contacts myContact = new ACMSLogic.Staff.Contacts();

            if (rbMale.Checked)
            {
                strGender = "M";
            }
            else if (rbFemale.Checked)
            {
                strGender = "F";
            }

            if (cbStatus.Text == "Active")
            {
                nStatus = 1;
            }
            else
            {
                nStatus = 0;
            }

            #region Validation
            if (strContactName.Length == 0)
            {
                UI.ShowErrorMessage(this, "Contact person is required.", "Error");

                //txtContactPerson.Focus();
                DialogResult = DialogResult.None;

                return;
            }

            if (strNRICFIN.Length != 0)
            {
                if (!IsSingaporeNric_S(strNRICFIN) && !IsSingaporeNric_T(strNRICFIN) && !IsFinValid(strNRICFIN))
                {
                    UI.ShowErrorMessage(this, "Invalid NRIC/FIN.", "Error");
                    //luedtMediaSource.Focus();

                    DialogResult = DialogResult.None;

                    return;
                }

                //if (strStatus == "New")
                //{
                //    if (myContact.CheckDupNRIC(strNRICFIN))
                //    {
                //        UI.ShowErrorMessage(this, "NRIC/FIN already exists in Lead Management System or Members' database.", "Error");

                //        DialogResult = DialogResult.None;

                //        return;
                //    }
                //}
            }

            if (strMobileNo.Length == 0)
            {
                UI.ShowErrorMessage(this, "Mobile No. is required.", "Error");

                //txtMobileNo.Focus();
                DialogResult = DialogResult.None;

                return;
            }

            //Mobile No invalid
            if (!IsMobileNoValid(strMobileNo))
            {
                UI.ShowErrorMessage(this, "Invalid Mobile No.", "Error");
                //luedtMediaSource.Focus();

                DialogResult = DialogResult.None;

                return;
            }

            //if (strStatus == "New")
            //{
            //    if (myContact.CheckDupMobileNo(strMobileNo))
            //    {
            //        UI.ShowErrorMessage(this, "Mobile No already exists in system.", "Error");

            //        DialogResult = DialogResult.None;

            //        return;
            //    }
            //}

            //Email Address invalid
            if (strEmail.Length != 0)
            {
                if (!IsEmailValid(strEmail))
                {
                    UI.ShowErrorMessage(this, "Invalid Email Address.", "Error");
                    //luedtMediaSource.Focus();

                    DialogResult = DialogResult.None;

                    return;
                }
            }

            if (rbMale.Checked == false && rbFemale.Checked == false)
            {
                UI.ShowErrorMessage(this, "Gender is required.", "Error");

                DialogResult = DialogResult.None;

                return;
            }

            if (cbPhoneCall.Checked == false && cbSMS.Checked == false && cbEmail.Checked == false)
            {
                UI.ShowErrorMessage(this, "Media preference is required.", "Error");

                DialogResult = DialogResult.None;

                return;
            }

            //if (rbDNCYes.Checked == false && rbDNCNo.Checked == false)
            //{
            //    UI.ShowErrorMessage(this, "DNC status is required.", "Error");

            //    DialogResult = DialogResult.None;

            //    return;
            //}

            if (luedtMediaSourceCategory.Text.Length == 0 || luedtMediaSource.Text.Length == 0)
            {
                UI.ShowErrorMessage(this, "Media Source is required.", "Error");
                //luedtMediaSource.Focus();

                DialogResult = DialogResult.None;

                return;
            }

            if (luedtAssigntoStaff.Text.Length == 0)
            {
                UI.ShowErrorMessage(this, "Please assign this new contact to a staff.", "Error");
                //luedtMediaSource.Focus();

                DialogResult = DialogResult.None;

                return;
            }
            if (chkMakeAppt.Checked) // Save Appointment
            {
                if (luedtServedBy.EditValue == "")
                {
                    UI.ShowErrorMessage(this, "Please assign this new contact serve by which staff.", "Error");
                    return;
                }
            }
            #endregion

            if (cbPhoneCall.Checked == true)
            {
                fPhoneCall = true;
            }

            if (cbSMS.Checked == true)
            {
                fSMS = true;
            }

            if (cbEmail.Checked == true)
            {
                fEmail = true;
            }

            if (rbDNCYes.Checked == true)
                fDNC = 1;

            if (rbDNCNo.Checked == true)
                fDNC = 0;

            nEmployeeID = Convert.ToInt32(luedtAssigntoStaff.EditValue);
            nMediaSourceID = Convert.ToInt32(luedtMediaSource.EditValue);

            if (dateedtDOB.Text.Length != 0)
            {
                dtDOB = dateedtDOB.DateTime;
            }

            if (nContactID < 0)
            {
                TblContacts myContacts = new TblContacts();

                myContacts.AddNewLead(ref myContactId, strContactName, strNRICFIN, strMobileNo, strEmail,
                                           strGender, dtDOB, nMediaSourceID, nEmployeeID,
                                           strBranchCode, strRemarks, fPhoneCall, fSMS,
                                           fEmail, fDNC, nEntryBy);

                if (myContactId > 0)
                {
                    try
                    {
                        SendConfirmation(myContactId.ToString().Trim(), strContactName.Trim(), strEmail.Trim(), ref myContacts);
                    }
                    catch (Exception ex)
                    {
                    }

                }

                DialogResult = DialogResult.OK;
            }
            else
            {
                TblContacts myContacts = new TblContacts();

                myContacts.UpdateLead(nContactID, strContactName, strNRICFIN, strMobileNo, strEmail,
                                        strGender, dtDOB, nMediaSourceID, nEmployeeID,
                                        strBranchCode, strRemarks, Convert.ToBoolean(nStatus), fPhoneCall, fSMS,
                                        fEmail, fDNC, nEntryBy);

                DialogResult = DialogResult.OK;
                myContactId = nContactID;
            }

            if (chkMakeAppt.Checked) // Save Appointment
            {
                ACMSLogic.Staff.Appointment myAppointment = new ACMSLogic.Staff.Appointment();
                DateTime StartDateTime = Convert.ToDateTime(dateedtStartTime.Text);
                DateTime EndDateTime = Convert.ToDateTime(dateedtEndTime.Text);
                int nServedBy = Convert.ToInt32(luedtServedBy.EditValue);

                myAppointment.NewAppoinment(nEmployeeID, dateedtDate.DateTime, StartDateTime,
                   EndDateTime, "", txtBranchCode.Text, myContactId, "", "", nServedBy);
            }
        }