Beispiel #1
0
 public static Common.PhoneNumber LoadNumber(Guid phoneNumberGuid)
 {
     Common.PhoneNumber   phoneNumber           = new Common.PhoneNumber();
     Business.PhoneNumber phoneNumberController = new Business.PhoneNumber();
     phoneNumberController.Load(phoneNumberGuid, phoneNumber);
     return(phoneNumber);
 }
Beispiel #2
0
 public static bool UpdateNumber(Common.PhoneNumber phoneNumber, Guid userGuid, Business.CheckNumberScope scope)
 {
     try
     {
         Business.PhoneNumber phoneNumberController = new Business.PhoneNumber();
         return(phoneNumberController.UpdateNumber(phoneNumber, userGuid, scope));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #3
0
        public bool InsertNumber(Common.PhoneNumber phoneNumber)
        {
            Guid guid = Guid.NewGuid();

            return(base.ExecuteSPCommand("InsertNumber",
                                         "@Guid", guid,
                                         "@FirstName", phoneNumber.FirstName,
                                         "@LastName", phoneNumber.LastName,
                                         "@NationalCode", phoneNumber.NationalCode,
                                         "@BirthDate", phoneNumber.BirthDate,
                                         "@CreateDate", phoneNumber.CreateDate,
                                         "@Telephone", phoneNumber.Telephone,
                                         "@CellPhone", phoneNumber.CellPhone,
                                         "@FaxNumber", phoneNumber.FaxNumber,
                                         "@Job", phoneNumber.Job,
                                         "@Address", phoneNumber.Address,
                                         "@Email", phoneNumber.Email,
                                         "@F1", phoneNumber.F1,
                                         "@F2", phoneNumber.F2,
                                         "@F3", phoneNumber.F3,
                                         "@F4", phoneNumber.F4,
                                         "@F5", phoneNumber.F5,
                                         "@F6", phoneNumber.F6,
                                         "@F7", phoneNumber.F7,
                                         "@F8", phoneNumber.F8,
                                         "@F9", phoneNumber.F9,
                                         "@F10", phoneNumber.F10,
                                         "@F11", phoneNumber.F11,
                                         "@F12", phoneNumber.F12,
                                         "@F13", phoneNumber.F13,
                                         "@F14", phoneNumber.F14,
                                         "@F15", phoneNumber.F15,
                                         "@F16", phoneNumber.F16,
                                         "@F17", phoneNumber.F17,
                                         "@F18", phoneNumber.F18,
                                         "@F19", phoneNumber.F19,
                                         "@F20", phoneNumber.F20,
                                         "@Sex", phoneNumber.Sex,
                                         "@PhoneBookGuid", phoneNumber.PhoneBookGuid));
        }
Beispiel #4
0
        public bool UpdateNumber(Common.PhoneNumber phoneNumber, Guid userGuid, Business.CheckNumberScope scope)
        {
            try
            {
                DataTable dataTableNumberStatus = new DataTable();
                if ((int)scope == (int)CheckNumberScope.DeleteDuplicateNumberInGroup)
                {
                    dataTableNumberStatus = FetchDataTable(@"SELECT [CellPhone] FROM [PhoneNumbers] 
																									WHERE [IsDeleted]=0 AND [Guid]!= @Guid AND [PhoneBookGuid] = @PhoneBookGuid AND [CellPhone] = @CellPhone AND [Email] = @Email"                                                                                                    ,
                                                           "@Guid", phoneNumber.PhoneNumberGuid,
                                                           "@PhoneBookGuid", phoneNumber.PhoneBookGuid,
                                                           "@CellPhone", phoneNumber.CellPhone,
                                                           "@Email", phoneNumber.Email);
                }

                else if ((int)scope == (int)CheckNumberScope.DeleteDuplicateNumberInTotalGroup)
                {
                    dataTableNumberStatus = FetchDataTable(@"SELECT [CellPhone] FROM 
																									[PhoneNumbers] number
																									INNER JOIN [PhoneBooks] phoneBook ON phoneBook.[Guid]=number.[PhoneBookGuid]
																									WHERE number.[IsDeleted] = 0 AND phoneBook.[IsDeleted] = 0 AND [UserGuid] = @UserGuid AND number.[Guid]!=@Guid AND [CellPhone] = @CellPhone AND [Email] = @Email"                                                                                                    ,
                                                           "@UserGuid", userGuid,
                                                           "@Guid", phoneNumber.PhoneNumberGuid,
                                                           "@CellPhone", phoneNumber.CellPhone,
                                                           "@Email", phoneNumber.Email);
                }
                if (dataTableNumberStatus.Rows.Count > 0)
                {
                    throw new Exception(Language.GetString("ErrorDuplicateNumber"));
                }

                return(base.ExecuteSPCommand("UpdateNumber",
                                             "@Guid", phoneNumber.PhoneNumberGuid,
                                             "@FirstName", phoneNumber.FirstName,
                                             "@LastName", phoneNumber.LastName,
                                             "@NationalCode", phoneNumber.NationalCode,
                                             "@BirthDate", phoneNumber.BirthDate,
                                             "@Telephone", phoneNumber.Telephone,
                                             "@CellPhone", phoneNumber.CellPhone,
                                             "@FaxNumber", phoneNumber.FaxNumber,
                                             "@Job", phoneNumber.Job,
                                             "@Address", phoneNumber.Address,
                                             "@Email", phoneNumber.Email,
                                             "@F1", phoneNumber.F1,
                                             "@F2", phoneNumber.F2,
                                             "@F3", phoneNumber.F3,
                                             "@F4", phoneNumber.F4,
                                             "@F5", phoneNumber.F5,
                                             "@F6", phoneNumber.F6,
                                             "@F7", phoneNumber.F7,
                                             "@F8", phoneNumber.F8,
                                             "@F9", phoneNumber.F9,
                                             "@F10", phoneNumber.F10,
                                             "@F11", phoneNumber.F11,
                                             "@F12", phoneNumber.F12,
                                             "@F13", phoneNumber.F13,
                                             "@F14", phoneNumber.F14,
                                             "@F15", phoneNumber.F15,
                                             "@F16", phoneNumber.F16,
                                             "@F17", phoneNumber.F17,
                                             "@F18", phoneNumber.F18,
                                             "@F19", phoneNumber.F19,
                                             "@F20", phoneNumber.F20,
                                             "@Sex", phoneNumber.Sex));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
 public static bool InsertNumber(Common.PhoneNumber phoneNumber)
 {
     Business.PhoneNumber phoneNumberController = new Business.PhoneNumber();
     return(phoneNumberController.InsertNumber(phoneNumber));
 }
        private void SetCustomFieldValue(Common.PhoneNumber phoneNumber, int customFieldId, string value, UserFieldTypes userFieldTypes)
        {
            try
            {
                DateTime date;
                switch (userFieldTypes)
                {
                case UserFieldTypes.Number:
                    if (!Helper.CheckDataConditions(value).IsIntNumber)
                    {
                        throw new Exception();
                    }
                    break;

                case UserFieldTypes.DateTime:
                    date = DateManager.GetChristianDateForDB(value);
                    if (date != DateTime.MinValue)
                    {
                        value = date.ToString();
                    }
                    break;
                }

                switch (customFieldId)
                {
                case 1:
                    phoneNumber.F1 = value;
                    break;

                case 2:
                    phoneNumber.F2 = value;
                    break;

                case 3:
                    phoneNumber.F3 = value;
                    break;

                case 4:
                    phoneNumber.F4 = value;
                    break;

                case 5:
                    phoneNumber.F5 = value;
                    break;

                case 6:
                    phoneNumber.F6 = value;
                    break;

                case 7:
                    phoneNumber.F7 = value;
                    break;

                case 8:
                    phoneNumber.F8 = value;
                    break;

                case 9:
                    phoneNumber.F9 = value;
                    break;

                case 10:
                    phoneNumber.F10 = value;
                    break;

                case 11:
                    phoneNumber.F11 = value;
                    break;

                case 12:
                    phoneNumber.F12 = value;
                    break;

                case 13:
                    phoneNumber.F13 = value;
                    break;

                case 14:
                    phoneNumber.F14 = value;
                    break;

                case 15:
                    phoneNumber.F15 = value;
                    break;

                case 16:
                    phoneNumber.F16 = value;
                    break;

                case 17:
                    phoneNumber.F17 = value;
                    break;

                case 18:
                    phoneNumber.F18 = value;
                    break;

                case 19:
                    phoneNumber.F19 = value;
                    break;

                case 20:
                    phoneNumber.F20 = value;
                    break;
                }
            }
            catch
            {
                throw new Exception(Language.GetString("CustomFieldValueIsInValid"));
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Common.PhoneNumber        phoneNumber;
            List <Common.PhoneNumber> lstNumbers = new List <Common.PhoneNumber>();
            string fieldId;
            string saveReport = string.Empty;

            try
            {
                string file = hdnFilePath.Value;

                if (!System.IO.File.Exists(Server.MapPath(string.Format("/Uploads/{0}", file))))
                {
                    throw new Exception(Language.GetString("FileDoesNotExist"));
                }

                string    extension = file.Substring(file.LastIndexOf('.')).TrimStart('.');
                bool      firstRowHasColumnNames = chbHeaderRow.Checked;
                DataTable dtb = new DataTable();

                switch (extension.ToLower())
                {
                case "csv":
                    dtb = ImportFile.ImportCSV(Server.MapPath(string.Format("/Uploads/{0}", file)), firstRowHasColumnNames);
                    break;

                case "xls":
                case "xlsx":
                    dtb = ImportFile.ImportExcel(Server.MapPath(string.Format("/Uploads/{0}", file)), firstRowHasColumnNames);
                    break;
                }

                foreach (DataRow row in dtb.Rows)
                {
                    phoneNumber = new Common.PhoneNumber();
                    phoneNumber.PhoneNumberGuid = Guid.NewGuid();
                    phoneNumber.PhoneBookGuid   = PhoneBookGuid;
                    phoneNumber.CreateDate      = DateTime.Now;
                    phoneNumber.FirstName       = !string.IsNullOrEmpty(txtFirstName.Text) ? row[Helper.GetInt(txtFirstName.Text.Trim()) - 1].ToString() : string.Empty;
                    phoneNumber.LastName        = !string.IsNullOrEmpty(txtLastName.Text) ? row[Helper.GetInt(txtLastName.Text.Trim()) - 1].ToString() : string.Empty;

                    if (!string.IsNullOrEmpty(txtBirthDate.Text))
                    {
                        phoneNumber.BirthDate = DateManager.GetChristianDateForDB(row[Helper.GetInt(txtBirthDate.Text.Trim()) - 1].ToString());
                    }

                    if (!string.IsNullOrEmpty(txtSex.Text))
                    {
                        phoneNumber.Sex = GetSex(row[Helper.GetInt(txtSex.Text.Trim()) - 1].ToString());
                    }

                    string mobile = !string.IsNullOrEmpty(txtCellPhone.Text) ? Helper.GetLocalMobileNumber(row[Helper.GetInt(txtCellPhone.Text.Trim()) - 1].ToString()) : string.Empty;
                    string email  = !string.IsNullOrEmpty(txtEmail.Text) ? row[Helper.GetInt(txtEmail.Text.Trim()) - 1].ToString() : string.Empty;

                    if (!Helper.CheckDataConditions(email).IsEmail)
                    {
                        email = string.Empty;
                    }

                    //if (!Helper.CheckingCellPhone(ref mobile) && !Helper.CheckDataConditions(email).IsEmail)
                    //	continue;

                    phoneNumber.Email     = email;
                    phoneNumber.CellPhone = mobile;
                    phoneNumber.Job       = !string.IsNullOrEmpty(txtJob.Text) ? row[Helper.GetInt(txtJob.Text.Trim()) - 1].ToString() : string.Empty;
                    phoneNumber.Telephone = !string.IsNullOrEmpty(txtTelephone.Text) ? row[Helper.GetInt(txtTelephone.Text.Trim()) - 1].ToString() : string.Empty;
                    phoneNumber.FaxNumber = !string.IsNullOrEmpty(txtFaxNumber.Text) ? row[Helper.GetInt(txtFaxNumber.Text.Trim()) - 1].ToString() : string.Empty;
                    phoneNumber.Address   = !string.IsNullOrEmpty(txtAddress.Text) ? row[Helper.GetInt(txtAddress.Text.Trim()) - 1].ToString() : string.Empty;

                    fieldId = string.Empty;
                    for (int customFieldCounter = 1; customFieldCounter <= 20; customFieldCounter++)
                    {
                        fieldId = "Field" + customFieldCounter.ToString();
                        TextBox customField = pnlUserField.FindControl(fieldId) as TextBox;
                        if (customField != null && !string.IsNullOrEmpty(customField.Text))
                        {
                            SetCustomFieldValue(phoneNumber,
                                                customFieldCounter,
                                                row[Helper.GetInt(customField.Text.Trim()) - 1].ToString(),
                                                (UserFieldTypes)Helper.GetInt(customField.Attributes["FieldType"]));
                        }
                    }

                    lstNumbers.Add(phoneNumber);
                }

                if (!Facade.PhoneNumber.InsertBulkNumbers(lstNumbers, UserGuid))
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                ClientSideScript = "saveResult('OK','" + Language.GetString("InsertRecord") + "');";

                hdnFilePath.Value = string.Empty;
            }
            catch (Exception ex)
            {
                ClientSideScript = "saveResult('Error','" + ex.Message + "');";
            }
        }
Beispiel #8
0
        private void InitializePage()
        {
            btnCancel.Text = Language.GetString("Cancel");

            foreach (Business.Gender sex in Enum.GetValues(typeof(Business.Gender)))
            {
                drpSex.Items.Add(new ListItem(Language.GetString(sex.ToString()), ((int)sex).ToString()));
            }
            drpSex.Items.Insert(0, new ListItem(string.Empty, string.Empty));

            foreach (Business.CheckNumberScope scope in Enum.GetValues(typeof(Business.CheckNumberScope)))
            {
                drpCheckNumberScope.Items.Add(new ListItem(Language.GetString(scope.ToString()), ((int)scope).ToString()));
            }

            if (ActionType == "edit")
            {
                string             customField = string.Empty;
                Common.PhoneNumber phoneNumber = Facade.PhoneNumber.LoadNumber(PhoneNumberGuid);

                txtFirstName.Text    = phoneNumber.FirstName;
                txtLastName.Text     = phoneNumber.LastName;
                txtNationalCode.Text = phoneNumber.NationalCode;
                if (phoneNumber.BirthDate != DateTime.MinValue)
                {
                    dtpBirthDate.Value = DateManager.GetSolarDate(phoneNumber.BirthDate);
                }
                txtTelephone.Text    = phoneNumber.Telephone;
                txtCellPhone.Text    = phoneNumber.CellPhone;
                txtFaxNumber.Text    = phoneNumber.FaxNumber;
                txtJob.Text          = phoneNumber.Job;
                txtAddress.Text      = phoneNumber.Address;
                txtEmail.Text        = phoneNumber.Email;
                drpSex.SelectedValue = Helper.GetString(phoneNumber.Sex);

                if (!Helper.CheckDataConditions(phoneNumber.F1).IsEmpty)
                {
                    customField += "Field1{(" + phoneNumber.F1 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F2).IsEmpty)
                {
                    customField += "Field2{(" + phoneNumber.F2 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F3).IsEmpty)
                {
                    customField += "Field3{(" + phoneNumber.F3 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F4).IsEmpty)
                {
                    customField += "Field4{(" + phoneNumber.F4 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F5).IsEmpty)
                {
                    customField += "Field5{(" + phoneNumber.F5 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F6).IsEmpty)
                {
                    customField += "Field6{(" + phoneNumber.F6 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F7).IsEmpty)
                {
                    customField += "Field7{(" + phoneNumber.F7 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F8).IsEmpty)
                {
                    customField += "Field8{(" + phoneNumber.F8 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F9).IsEmpty)
                {
                    customField += "Field9{(" + phoneNumber.F9 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F10).IsEmpty)
                {
                    customField += "Field10{(" + phoneNumber.F10 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F11).IsEmpty)
                {
                    customField += "Field11{(" + phoneNumber.F11 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F12).IsEmpty)
                {
                    customField += "Field12{(" + phoneNumber.F12 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F13).IsEmpty)
                {
                    customField += "Field13{(" + phoneNumber.F13 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F14).IsEmpty)
                {
                    customField += "Field14{(" + phoneNumber.F14 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F15).IsEmpty)
                {
                    customField += "Field15{(" + phoneNumber.F15 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F16).IsEmpty)
                {
                    customField += "Field16{(" + phoneNumber.F16 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F17).IsEmpty)
                {
                    customField += "Field17{(" + phoneNumber.F17 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F18).IsEmpty)
                {
                    customField += "Field18{(" + phoneNumber.F18 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F19).IsEmpty)
                {
                    customField += "Field19{(" + phoneNumber.F19 + ")}";
                }
                if (!Helper.CheckDataConditions(phoneNumber.F20).IsEmpty)
                {
                    customField += "Field20{(" + phoneNumber.F20 + ")}";
                }

                ClientSideScript = "customField('" + GenerateCustomField(customField) + "')";
            }
            else
            {
                ClientSideScript = "customField('" + GenerateCustomField(string.Empty) + "')";
            }
        }
        public HttpResponseMessage Register(PhoneBookModel phonebookInfo)
        {
            Common.PhoneNumber        phoneNumber;
            List <Common.PhoneNumber> lstNumbers = new List <Common.PhoneNumber>();

            var principal = Thread.CurrentPrincipal;

            if (!principal.Identity.IsAuthenticated)
            {
                throw new BusinessException(HttpStatusCode.Accepted, ErrorCode.AccountIsInvalid, Language.GetString("AccountIsInvalid"));
            }

            if (phonebookInfo.PhoneBookGuid == Guid.Empty ||
                phonebookInfo.Numbers.Count > 100 ||
                phonebookInfo.Numbers.Count == 0)
            {
                throw new BusinessException(HttpStatusCode.Accepted, ErrorCode.BadRequest, Language.GetString("BadRequest"));
            }

            Common.User userInfo = ((MyPrincipal)principal).UserDetails;

            Parallel.ForEach <PostPhoneNumberModel>(phonebookInfo.Numbers, (numberInfo) =>
            {
                numberInfo.Mobile           = Helper.GetLocalMobileNumber(numberInfo.Mobile);
                phoneNumber                 = new Common.PhoneNumber();
                phoneNumber.PhoneNumberGuid = Guid.NewGuid();
                phoneNumber.FirstName       = numberInfo.FirstName;
                phoneNumber.LastName        = numberInfo.LastName;
                phoneNumber.BirthDate       = numberInfo.BirthDate;
                phoneNumber.CreateDate      = DateTime.Now;
                phoneNumber.Telephone       = numberInfo.Telephone;
                phoneNumber.CellPhone       = numberInfo.Mobile;
                phoneNumber.FaxNumber       = numberInfo.FaxNumber;
                phoneNumber.Job             = numberInfo.Job;
                phoneNumber.Address         = numberInfo.Address;
                phoneNumber.Email           = numberInfo.Email;
                phoneNumber.Sex             = Helper.GetByte(numberInfo.Gender);
                phoneNumber.PhoneBookGuid   = phonebookInfo.PhoneBookGuid;

                if (Helper.IsCellPhone(numberInfo.Mobile) != 0)
                {
                    lstNumbers.Add(phoneNumber);
                }
            });

            if (lstNumbers.Count == 0)
            {
                throw new BusinessException(HttpStatusCode.Accepted, ErrorCode.ReceiversIsEmpty, Language.GetString("ReceiversIsEmpty"));
            }

            if (!Facade.PhoneNumber.InsertBulkNumbers(lstNumbers, userInfo.UserGuid))
            {
                throw new Exception(Language.GetString("ErrorRecord"));
            }

            ResponseMessage response = new ResponseMessage();

            response.IsSuccessful = true;

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }