Exemplo n.º 1
0
        public void ValidateTest()
        {
            var newMember = new Entities.Member()
            {
                Name          = "John Doe",
                Email         = "",
                OptionalEmail = "",
                DateOfBirth   = DateTime.Parse("1999-01-01"),
                Gender        = "Male",
                MobileNumber  = "",
                Password      = ""
            };

            try
            {
                ModelValidator.Validate(newMember);
                Assert.Fail("This text should never be printed, validate method should throw an exception");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is ValidationException);
                var validationEx = ex as ValidationException;
                Assert.IsTrue(validationEx.ValidationResult.Errors.Count == 3);

                //Validate where field error names are below
                Assert.IsTrue(validationEx.ValidationResult.Errors.Where(x => x.Field == nameof(Member.Email)).Count() == 1);
                Assert.IsTrue(validationEx.ValidationResult.Errors.Where(x => x.Field == nameof(Member.Password)).Count() == 1);
                Assert.IsTrue(validationEx.ValidationResult.Errors.Where(x => x.Field == nameof(Member.MobileNumber)).Count() == 1);
            }
        }
        public void AddUser(string jsonString)
        {
            using (var session = FluentNHibernateConfiguration.InitFactory.sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    JObject jsonObject = JObject.Parse(jsonString);
                    var user = new Entities.Member
                    {
                        memberFirstName = jsonObject.SelectToken("firstName").ToString(),
                        memberLastName = jsonObject.SelectToken("lastName").ToString(),
                        userName = jsonObject.SelectToken("userName").ToString(),
                        memberPassword = jsonObject.SelectToken("password").ToString(),
                        memberEmail = jsonObject.SelectToken("email").ToString()
                    };

                    JavaScriptSerializer js = new JavaScriptSerializer();
                    DateTime dt = new DateTime();
                    user.memberHash = util.UtilityMethods.CalculateMD5Hash(user.userName + dt.ToShortTimeString());
                    Context.Response.Write(js.Serialize(new Response3 { LogIn = 1, twocubeSSO = user.memberHash }));
                    session.Save(user);
                    transaction.Commit();

                }
            }
        }
Exemplo n.º 3
0
        public async Task <Entities.TeamoEntry> AddMemberAsync(Entities.Member member, Entities.ClientMessage message)
        {
            return(await ExclusiveAsync(async() =>
            {
                _logger.LogInformation("Adding member!\n" +
                                       $"message id: {message.MessageId}\n" +
                                       $"channel id: {message.ChannelId}\n" +
                                       $"server id: {message.ServerId}\n"
                                       );

                var post = Posts.Single(
                    (a) =>
                    a.Message.MessageId == message.MessageId &&
                    a.Message.ChannelId == message.ChannelId &&
                    a.Message.ServerId == message.ServerId
                    );

                if (post.Members.Exists((a) => a.ClientUserId == member.ClientUserId))
                {
                    _logger.LogWarning($"Trying to add member {member.ClientUserId} to database, but member already exists. Updating numPlayers instead.");
                    post.Members.Single((a) => a.ClientUserId == member.ClientUserId).NumPlayers = member.NumPlayers;
                }
                else
                {
                    post.Members.Add(new Member()
                    {
                        ClientUserId = member.ClientUserId,
                        NumPlayers = member.NumPlayers
                    });
                }
                await SaveChangesAsync();
                return post.AsEntityType();
            }));
        }
Exemplo n.º 4
0
 public static Models.Member AsModelType(this Entities.Member entitiesMember)
 {
     return(new Models.Member
     {
         ClientUserId = entitiesMember.ClientUserId,
         NumPlayers = entitiesMember.NumPlayers
     });
 }
Exemplo n.º 5
0
        public void RegisterNewMemberTest()
        {
            var service   = new MemberService(repo, hasher);
            var newMember = service.RegisterNewMember(new Entities.Member()
            {
                ID            = 100,
                Name          = "John Doe",
                Email         = "*****@*****.**",
                OptionalEmail = "",
                DateOfBirth   = DateTime.Parse("1999-01-01"),
                Gender        = "Male",
                MobileNumber  = "",
                Password      = "******"
            });

            var expectedNewMemberID = 1;
            var actualNewMemberID   = newMember.ID;

            if (expectedNewMemberID != actualNewMemberID)
            {
                Assert.Fail("New member id should be {0}, but got {1}", expectedNewMemberID, actualNewMemberID);
            }

            var expectedRecordsCount = 1;
            var actualRecordsCount   = repo.Members.Count;

            if (expectedRecordsCount != actualRecordsCount)
            {
                Assert.Fail("Records count should be {0}, but got {1}", expectedRecordsCount, actualRecordsCount);
            }

            var expectedRecord = new Entities.Member()
            {
                ID            = 1,
                Name          = "John Doe",
                Email         = "*****@*****.**",
                OptionalEmail = "",
                DateOfBirth   = DateTime.Parse("1999-01-01"),
                Gender        = "Male",
                MobileNumber  = "",
                Password      = "******"
            };

            var actualRecord = service.GetMember(newMember.ID);

            Assert.AreEqual(expectedRecord.ID, actualRecord.ID);
            Assert.AreEqual(expectedRecord.Name, actualRecord.Name);
            Assert.AreEqual(expectedRecord.Email, actualRecord.Email);
            Assert.AreEqual(expectedRecord.OptionalEmail, actualRecord.OptionalEmail);
            Assert.AreEqual(expectedRecord.DateOfBirth, actualRecord.DateOfBirth);
            Assert.AreEqual(expectedRecord.Gender, actualRecord.Gender);
            Assert.AreEqual(expectedRecord.MobileNumber, actualRecord.MobileNumber);
            Assert.IsTrue(new BCryptHasher().Verify(expectedRecord.Password, actualRecord.Password));
        }
Exemplo n.º 6
0
        public void GetMemberTest()
        {
            var service       = new MemberService(repo, hasher);
            var plainPassword = "******";
            var registrant    = new Entities.Member()
            {
                Name          = "John Doe",
                Email         = "*****@*****.**",
                OptionalEmail = "",
                DateOfBirth   = DateTime.Parse("1999-01-01"),
                Gender        = "Male",
                MobileNumber  = "",
                Password      = plainPassword
            };

            service.RegisterNewMember(registrant);
            var existingMember = service.GetMember(registrant.ID);

            Assert.IsNotNull(existingMember);
            Assert.IsNotNull(existingMember.ID == 1);
        }
Exemplo n.º 7
0
        public void UpdateTest()
        {
            var repo           = new MemberRepository(InitializeData());
            var existingMember = new Entities.Member()
            {
                ID            = 1,
                Name          = "John Doe",
                Email         = "*****@*****.**",
                OptionalEmail = "*****@*****.**",
                DateOfBirth   = DateTime.Now,
                Gender        = "Male",
                MobileNumber  = "",
                Password      = "******"
            };
            var updatedMember = repo.Update(existingMember);

            Assert.IsNotNull(updatedMember);
            var fetchedMember = repo.GetById(updatedMember.ID);

            Assert.IsTrue(fetchedMember.OptionalEmail == "*****@*****.**");
            Assert.IsTrue(fetchedMember.Email == "*****@*****.**"); //Make sure that primary email is not changed
        }
Exemplo n.º 8
0
 public async Task AddMemberAsync(Entities.Member member, Entities.ClientMessage message)
 {
     var   entry = _dbContext.GetEntry(message);
     await _timers[entry.Id.Value].AddMemberAsync(member);
 }
Exemplo n.º 9
0
        public void LoadData()
        {
            //load membertype
            DataTable dt = new DataTable();

            dt = memberTypeBLL.GetListsNameNotNull();
            if (dt != null)
            {
                lstMemberType.DataSource = dt;
                if (Common.clsLanguages.StrCulture.Equals("vi-VN"))
                {
                    lstMemberType.DisplayMember = dt.Columns["MemberTypeName"].ToString();
                }
                else if (Common.clsLanguages.StrCulture.Equals("en-US"))
                {
                    lstMemberType.DisplayMember = dt.Columns["MemberTypeName3"].ToString();
                }
                else if (Common.clsLanguages.StrCulture.Equals("ja-JP"))
                {
                    lstMemberType.DisplayMember = dt.Columns["MemberTypeName2"].ToString();
                }

                lstMemberType.ValueMember = dt.Columns["MemberTypeId"].ToString();
            }
            //load data for cbb nationality
            DataTable dtCountry = new DataTable();

            dtCountry = countryBLL.GetLists();
            if (dtCountry != null)
            {
                this.cbbNationality.DataSource = dtCountry;
                if (Common.clsLanguages.StrCulture.Equals("vi-VN"))
                {
                    this.cbbNationality.DisplayMember = dtCountry.Columns["CountryName"].ToString();
                }
                else if (Common.clsLanguages.StrCulture.Equals("en-US"))
                {
                    this.cbbNationality.DisplayMember = dtCountry.Columns["CountryName3"].ToString();
                }
                else if (Common.clsLanguages.StrCulture.Equals("ja-JP"))
                {
                    this.cbbNationality.DisplayMember = dtCountry.Columns["CountryName2"].ToString();
                }
                this.cbbNationality.ValueMember = dtCountry.Columns["CountryId"].ToString();
            }
            //Điệp add 20140418

            //load data for cbb CallName
            DataTable dtCallName = new DataTable();

            dtCallName = callnameBLL.GetLists();
            if (dtCallName != null)
            {
                this.cbBCallName.DataSource  = dtCallName;
                this.cbBCallName.ValueMember = dtCallName.Columns["CallNameID"].ToString();
                if (Common.clsLanguages.StrCulture.Equals("vi-VN"))
                {
                    this.cbBCallName.DisplayMember = dtCallName.Columns["Name1"].ToString();
                }
                else if (Common.clsLanguages.StrCulture.Equals("en-US"))
                {
                    this.cbBCallName.DisplayMember = dtCallName.Columns["Name2"].ToString();
                }
                else if (Common.clsLanguages.StrCulture.Equals("ja-JP"))
                {
                    for (int i = 1; i < dtCallName.Rows.Count; i++)
                    {
                        dtCallName.Rows[i].Delete();
                    }

                    this.cbBCallName.DisplayMember = dtCallName.Columns["Name3"].ToString();
                    this.cbBCallName.SelectedIndex = (Common.clsLanguages.StrCulture.Equals("ja-JP")) ? 0 : dtCallName.Rows.Count - 1;
                }
            }

            //End Điệp add 20140418

            //Begin Linh 25-12-2014
            #region ComboBox cbb CategoryActions
            DataTable dtCategory = new DataTable();
            dtCategory = categoryactionsBLL.GetLists();
            if (dtCategory != null)
            {
                this.cbBCategoryAction.DataSource = dtCategory;

                if (Common.clsLanguages.StrCulture.Equals("vi-VN"))
                {
                    this.cbBCategoryAction.DisplayMember = dtCategory.Columns["CategoryActionName"].ToString();
                }
                else if (Common.clsLanguages.StrCulture.Equals("en-US"))
                {
                    this.cbBCategoryAction.DisplayMember = dtCategory.Columns["CategoryActionName3"].ToString();
                }
                else if (Common.clsLanguages.StrCulture.Equals("ja-JP"))
                {
                    this.cbBCategoryAction.DisplayMember = dtCategory.Columns["CategoryActionName2"].ToString();
                }
                this.cbBCategoryAction.ValueMember   = dtCategory.Columns["CategoryActionID"].ToString();
                this.cbBCategoryAction.SelectedIndex = 1;
            }

            #endregion End CategoryAction
            //End Linh 25-12-2014

            //load data for cbb Employee
            DataTable dtEmployee = new DataTable();
            dtEmployee = employeeBLL.GetLists();
            if (dtEmployee != null)
            {
                this.cbbCurator.DataSource    = dtEmployee;
                this.cbbCurator.DisplayMember = dtEmployee.Columns["EmployeeName"].ToString();
                this.cbbCurator.ValueMember   = dtEmployee.Columns["EmployeeId"].ToString();
            }
            if (staticmemberId == null)
            {
                blag = true;
                this.cbbNationality.SelectedIndex = 0;
                this.chbIsLock.Visible            = false;
                this.dtpLockDate.Visible          = false;
                this.lblLockDate.Visible          = false;
                try
                {
                    cbbCurator.SelectedValue = Program.employee1.EmployeeId;
                }
                catch (Exception) { }
            }
            else
            {
                Entities.Member member = new Entities.Member();
                member = memberBLL.GetById(staticmemberId);
                this.txtMemberCode.Text = member.MemberCode;
                this.txtMemerName.Text  = member.MemberName;
                if (member.birthDay == true)
                {
                    this.chkNgaySinh.Checked = true;
                    dtpBirthDate.Enabled     = true;
                }
                else
                {
                    this.chkNgaySinh.Checked = false;
                    dtpBirthDate.Enabled     = false;
                }

                this.txtChucDanh.Text             = member.Regency;
                this.dtpBirthDate.Value           = member.BirthDate;
                this.txtEmail.Text                = member.Email;
                this.txtPhoneNumber.Text          = member.PhoneNumber;
                this.txtAddress.Text              = member.Address;
                this.cbbNationality.SelectedValue = member.Country.CountryId;
                this.txtTotalScore.Text           = member.TotalScore.ToString();
                this.txtNumberOfVissits.Text      = member.NumberOfVissits.ToString();
                this.dtpLastDate.Value            = member.LastestDate;
                this.dtpCreatedDate.Value         = member.CreatedDate;
                this.dtpUpdatedDate.Value         = member.UpdatedDate;
                //Linh 29-12-2014
                try
                {
                    this.cbbCurator.SelectedValue        = member.Curator.EmployeeId;
                    this.cbBCategoryAction.SelectedValue = member.CategoryID.CategoryActionID;
                }
                catch (Exception)
                {
                    this.cbbCurator.SelectedValue        = Program.employee1.EmployeeId;
                    this.cbBCategoryAction.SelectedIndex = 1;
                }


                //Điệp edit
                this.txtCurrentScore.Text = member.CurrentScore.ToString();

                List <string> lstMemberTypeName = new List <string>();
                ///
                List <int> lst_mbt = new List <int>();
                if (member.List_MemberType != null)
                {
                    foreach (Entities.MemberType mt in member.List_MemberType)
                    {
                        lst_mbt.Add(mt.MemberTypeId);
                    }
                }

                lstMemberTypeName = memberTypeBLL.GetListMemberTypeName_New(lst_mbt);
                for (int i = 0; i < lstMemberType.Items.Count; i++)
                {
                    /* string[] arr = lstMemberType.GetItemText(lstMemberType.Items[i]).Split('/');
                     * for (int j = 0; j < lstMemberTypeName.Count; j++)
                     * {
                     *   if (arr[0].Equals(lstMemberTypeName[j]))
                     *   {
                     *       lstMemberType.SetItemChecked(i, true);
                     *       break;
                     *   }
                     * }
                     */
                    int index = int.Parse(((DataRowView)lstMemberType.Items[i])["MemberTypeId"].ToString());
                    if (lst_mbt.Contains(index))
                    {
                        lstMemberType.SetItemChecked(i, true);
                    }
                }

                if (member.IsLock == 1)
                {
                    chbIsLock.Checked   = true;
                    lblLockDate.Visible = true;
                    dtpLockDate.Visible = true;
                }
                else
                {
                    lblLockDate.Visible = false;
                    dtpLockDate.Visible = false;
                }

                if (member.LockDate != new DateTime())
                {
                    this.dtpLockDate.Value = member.LockDate;
                }

                //Điệp Add 20140418
                this.txtMobilePhone.Text = member.MobilePhone;
                this.txtWebsite.Text     = member.Website;
                this.txtTaxCode.Text     = member.TaxCode;
                this.txtCompanyName.Text = member.CompanyName;
                this.txtDescription.Text = System.Text.RegularExpressions.Regex.Replace(member.Description, "\n", "\r\n");

                if (!Common.clsLanguages.StrCulture.Equals("ja-JP"))
                {
                    this.cbBCallName.SelectedValue = member.CallName.CallNameID;
                }
                this.txtCompanyEmail.Text = member.Email;
                //End Điệp add 20140418
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Event raise when user click save button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Entities.Member member = new Entities.Member();
                //memberId
                member.MemberId = staticmemberId;
                //validate member code
                string strMemberCode = "";
                if (chBAutoID.Checked)
                {
                    member.MemberCode = GetAutoMemberCode(cbbNationality.SelectedValue.ToString());
                }
                else
                {
                    strMemberCode = txtMemberCode.Text.Trim();
                    if (string.IsNullOrEmpty(strMemberCode))
                    {
                        CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM37"),
                                                                         Common.clsLanguages.GetResource("CRM11"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                        return;
                    }
                    else
                    {
                        member.MemberCode = strMemberCode;
                    }
                }
                //validate membername or company name not ether null

                if (string.IsNullOrEmpty(txtMemerName.Text.Trim()) && string.IsNullOrEmpty(txtCompanyName.Text.Trim()))
                {
                    CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM628"),
                                                                     Common.clsLanguages.GetResource("CRM11"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Error,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                    return;
                }
                else
                {
                    member.MemberName  = txtMemerName.Text.Trim();
                    member.CompanyName = txtCompanyName.Text.Trim();
                }

                //validate birthdate
                DateTime birthdate = dtpBirthDate.Value;
                member.BirthDate = birthdate;
                if (chkNgaySinh.Checked == true)
                {
                    member.birthDay = true;
                }
                else
                {
                    member.birthDay = false;
                }

                //validate email
                string   strEmail = txtCompanyEmail.Text.Trim();
                string[] emails   = strEmail.Split(';');
                int      lenght   = emails.Length;
                string   opSpace  = "";
                strEmail = "";

                for (int i = 0; i < lenght; i++)
                {
                    if (!string.IsNullOrEmpty(emails[i]) && !Common.Validation.ValidateEmail(emails[i].Trim()))
                    {
                        CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM311"),
                                                                         Common.clsLanguages.GetResource("CRM11"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                        return;
                    }

                    strEmail += opSpace + emails[i];
                    opSpace   = ";";
                }

                member.CompanyEmail = strEmail;

                member.Email = strEmail;

                //phone number
                member.PhoneNumber = System.Text.RegularExpressions.Regex.Replace(txtPhoneNumber.Text.Trim(), "( ( )*)", " ");


                //address
                if (!string.IsNullOrEmpty(txtAddress.Text.Trim()))
                {
                    member.Address = txtAddress.Text.Trim();
                }

                //validate nationality
                if (cbbNationality.Text == "")
                {
                    CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM373"),
                                                                     Common.clsLanguages.GetResource("CRM11"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                    return;
                }
                else
                {
                    member.Country.CountryId = cbbNationality.SelectedValue.ToString();
                }

                //creator
                member.Creator.EmployeeId = Program.employee1.EmployeeId;
                try
                {
                    member.Curator.EmployeeId = cbbCurator.SelectedValue.ToString();
                }
                catch
                {
                    member.Curator.EmployeeId = null;
                }
                try
                {
                    if (cbBCategoryAction.SelectedValue.ToString() != "")
                    {
                        member.CategoryID.CategoryActionID = cbBCategoryAction.SelectedValue.ToString();
                    }
                    else
                    {
                        member.CategoryID.CategoryActionID = "";
                    }
                }
                catch (Exception)
                {
                    member.CategoryID.CategoryActionID = "";
                }


                //chuc vu
                member.Regency = txtChucDanh.Text.Trim();

                //total score
                string strTotalScore = txtTotalScore.Text.Trim();
                if (!string.IsNullOrEmpty(strTotalScore))
                {
                    if (!Common.Validation.ValidateNumber(strTotalScore))
                    {
                        CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM98"),
                                                                         Common.clsLanguages.GetResource("CRM12"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Error,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                        return;
                    }
                    else
                    {
                        member.TotalScore = Int32.Parse(strTotalScore);
                    }
                }
                //total CurrentScore
                string strCurrentScore = txtCurrentScore.Text.Trim();
                if (!string.IsNullOrEmpty(strCurrentScore))
                {
                    if (!Common.Validation.ValidateNumber(strCurrentScore))
                    {
                        CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM98"),
                                                                         Common.clsLanguages.GetResource("CRM12"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Error,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                        return;
                    }
                    else
                    {
                        member.CurrentScore = Int32.Parse(strCurrentScore);
                    }
                }

                //numberOfVissits
                string strNumberOfVissits = txtNumberOfVissits.Text.Trim();
                if (!string.IsNullOrEmpty(strNumberOfVissits))
                {
                    if (!Common.Validation.ValidateNumber(strNumberOfVissits))
                    {
                        CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM98"),
                                                                         Common.clsLanguages.GetResource("CRM12"),
                                                                         Common.Config.CUSTOM_MESSAGEBOX_ICON.Error,
                                                                         Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                        return;
                    }
                    else
                    {
                        member.NumberOfVissits = Int32.Parse(strNumberOfVissits);
                    }
                }

                //member type
                //List<string> lstMemberTypeName = new List<string>();
                List <Entities.MemberType> lstMemberTypeName = new List <Entities.MemberType>();
                int otherIndex = -1;
                for (int i = 0; i < lstMemberType.Items.Count; i++)
                {
                    DataRowView dr = (DataRowView)lstMemberType.Items[i];
                    if (lstMemberType.GetItemChecked(i))
                    {
                        Entities.MemberType mt = new Entities.MemberType();
                        mt.MemberTypeId    = int.Parse(dr["MemberTypeId"].ToString());
                        mt.MemberTypeName  = dr["MemberTypeName"].ToString();
                        mt.MemberTypeName2 = dr["MemberTypeName2"].ToString();
                        mt.MemberTypeName3 = dr["MemberTypeName3"].ToString();
                        //mt.MemberTypeId
                        lstMemberTypeName.Add(mt);
                    }
                    if (dr["MemberTypeCode"].ToString().Equals("OT")) // other type
                    {
                        otherIndex = i;
                    }
                }
                if (lstMemberTypeName.Count != 0)
                {
                    member.List_MemberType = lstMemberTypeName;
                }
                else
                {
                    if (otherIndex >= 0)
                    {
                        DataRowView         dr = (DataRowView)lstMemberType.Items[otherIndex];
                        Entities.MemberType mt = new Entities.MemberType();
                        mt.MemberTypeId    = int.Parse(dr["MemberTypeId"].ToString());
                        mt.MemberTypeName  = dr["MemberTypeName"].ToString();
                        mt.MemberTypeName2 = dr["MemberTypeName2"].ToString();
                        mt.MemberTypeName3 = dr["MemberTypeName3"].ToString();
                        lstMemberTypeName.Add(mt);

                        member.List_MemberType = lstMemberTypeName;
                    }
                    else
                    {
                        member.List_MemberType = null;
                    }
                }

                //member.MemberType.MemberTypeId = Int32.Parse(memberType);

                //Lastest Date
                member.LastestDate = DateTime.Now;
                //Created date
                member.CreatedDate = DateTime.Now;
                //Updated date
                member.UpdatedDate = DateTime.Now;

                //islock
                int isLock = 0;
                if (chbIsLock.Checked)
                {
                    isLock = 1;
                }
                member.IsLock = isLock;

                //LockDate
                member.LockDate    = DateTime.Now;
                member.MobilePhone = txtMobilePhone.Text.Trim();

                //validate website
                string url = txtWebsite.Text.Trim();

                if (!string.IsNullOrEmpty(url) && !Common.Validation.ValidateWebsite(url))
                {
                    CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRMErrorURLNotValid"),
                                                                     Common.clsLanguages.GetResource("CRM12"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Error,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                    return;
                }

                member.Website = url;

                member.TaxCode     = txtTaxCode.Text.Trim();
                member.Description = txtDescription.Text.Trim();
                if (cbBCallName.SelectedValue != null)
                {
                    member.CallName.CallNameID = (int)cbBCallName.SelectedValue;
                }


                DialogResult dialog = CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM227"),
                                                                                       Common.clsLanguages.GetResource("CRM11"),
                                                                                       Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                                       Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO);
                if (dialog == DialogResult.Yes)
                {
                    //If is add
                    if (blag)
                    {
                        if (memberBLL.CheckMemberCodeExist(strMemberCode))
                        {
                            CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM539"),
                                                                             Common.clsLanguages.GetResource("CRM12"),
                                                                             Common.Config.CUSTOM_MESSAGEBOX_ICON.Error,
                                                                             Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                            this.txtMemberCode.Clear();
                            this.txtMemberCode.Focus();
                            return;
                        }
                        memberBLL.Add(member);

                        if (staticmemberId != null)
                        {
                            staticmemberId = member.MemberId;
                        }
                    }
                    //If is edit
                    else
                    {
                        memberBLL.Edit(member);
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM292"),
                                                                 Common.clsLanguages.GetResource("CRM12"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
                return;
            }
        }
        public void Insert()
        {
            using (var session = FluentNHibernateConfiguration.InitFactory.sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var user = new Entities.Member { userName = "******", memberPassword = "******" };

                    var survey = new Entities.Survey { surveyDescription = "A Random Sample Survey. This is just a sample of how json can be used to render a survey.", surveyTitle = "Sample Survey", surveyQuestionList = new List<Entities.SurveyQuestion>() };
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "What is your, favourite, color?", surveyQuestionType = 0, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(0).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "White" });
                    survey.surveyQuestionList.ElementAt(0).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Yellow" });
                    survey.surveyQuestionList.ElementAt(0).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Blue" });
                    survey.surveyQuestionList.ElementAt(0).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Green" });
                    survey.surveyQuestionList.ElementAt(0).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Enter another color:", surveyQuestionOptionType = 2 });
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "Who is the most hardworking person in our team?", surveyQuestionType = 0, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(1).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "June" });
                    survey.surveyQuestionList.ElementAt(1).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/weileng.peh/picture?type=large", surveyQuestionOptionTitleType = 2 });
                    survey.surveyQuestionList.ElementAt(1).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Hong Jing" });
                    survey.surveyQuestionList.ElementAt(1).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Xu Ai" });
                    survey.surveyQuestionList.ElementAt(1).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Wesley" });
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "And the best phone is", surveyQuestionType = 0, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(2).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Galaxy S 3" });
                    survey.surveyQuestionList.ElementAt(2).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Galaxy S 2" });
                    survey.surveyQuestionList.ElementAt(2).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Galaxy S" });
                    survey.surveyQuestionList.ElementAt(2).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "HTC One X" });
                    survey.surveyQuestionList.ElementAt(2).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Galaxy Nexus" });
                    survey.surveyQuestionList.ElementAt(2).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Motorola Droid Razr Maxx" });
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "Who is the most hardworking person in our team? (You can choose more than 1 answer)", surveyQuestionType = 1, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/weileng.peh/picture?type=large", surveyQuestionOptionTitleType = 2 });
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "June" });
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "June" });
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "June" });
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "June" });
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "June" });
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "June" });
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "June" });
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "June" });
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "How hardworking is June?", surveyQuestionType = 2, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(4).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "Hardworkingness" , surveyQuestionOptionMaxText="Very Very Hardworking", surveyQuestionOptionMinText="Very Hardworking"});
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "How young is this pretty young star? Numeric input.", surveyQuestionType = 3, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(5).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/weileng.peh/picture?type=large" });
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "Or the birthday of this talented actor/singer? Date input.", surveyQuestionType = 4, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(6).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/197371292379/picture?type=large" });
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "Which picture is the odd one out?", surveyQuestionType = 5, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(7).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/alexei.sourin/picture?type=square" , surveyQuestionOptionTitleType=2 });
                    survey.surveyQuestionList.ElementAt(7).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "test", surveyQuestionOptionTitleType = 0 });
                    survey.surveyQuestionList.ElementAt(7).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/bengkoon.ng/picture?type=square", surveyQuestionOptionTitleType = 2 });
                    survey.surveyQuestionList.ElementAt(7).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/bingsheng.he/picture?type=square", surveyQuestionOptionTitleType = 2 });
                    survey.surveyQuestionList.ElementAt(7).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/limws.brandon/picture?type=square", surveyQuestionOptionTitleType = 2 });
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "Please give your opinion of this survey in a single sentence.", surveyQuestionType = 6, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(8).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/197371292379/picture?type=large" });
                    survey.surveyQuestionList.Add(new Entities.SurveyQuestion { surveyQuestionTitle = "Opinon. In. A. Paragraph.", surveyQuestionType = 7, surveyQuestionOptionList = new List<Entities.SurveyQuestionOption>() });
                    survey.surveyQuestionList.ElementAt(9).surveyQuestionOptionList.Add(new Entities.SurveyQuestionOption { surveyQuestionOptionTitle = "http://graph.facebook.com/197371292379/picture?type=large" });
                    var respondent = new Entities.Respondent { respondentIPAddress = "127.0.0.1", respondentSessionID = "randomid" };

                    var responseqn0 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 1 };
                    respondent.surveyQuestionResponseList.Add(responseqn0);
                    survey.surveyQuestionList.ElementAt(0).surveyQuestionResponseList.Add(responseqn0);
                    var responseqn1 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 3 };
                    respondent.surveyQuestionResponseList.Add(responseqn1);
                    survey.surveyQuestionList.ElementAt(1).surveyQuestionResponseList.Add(responseqn1);
                    var responseqn2 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 4 };
                    respondent.surveyQuestionResponseList.Add(responseqn2);
                    survey.surveyQuestionList.ElementAt(2).surveyQuestionResponseList.Add(responseqn2);
                    var responseqn30 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 2 };
                    var responseqn31 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 3 };
                    var responseqn32 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 6 };
                    respondent.surveyQuestionResponseList.Add(responseqn30);
                    respondent.surveyQuestionResponseList.Add(responseqn31);
                    respondent.surveyQuestionResponseList.Add(responseqn32);
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionResponseList.Add(responseqn30);
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionResponseList.Add(responseqn31);
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionResponseList.Add(responseqn32);
                    var responseqn4 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 2, responseStringValue = "100" };
                    respondent.surveyQuestionResponseList.Add(responseqn4);
                    survey.surveyQuestionList.ElementAt(4).surveyQuestionResponseList.Add(responseqn4);
                    var responseqn5 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 2, responseIntegerValue = 3, responseStringValue = "345" };
                    respondent.surveyQuestionResponseList.Add(responseqn5);
                    survey.surveyQuestionList.ElementAt(5).surveyQuestionResponseList.Add(responseqn5);
                    var responseqn6 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 2, responseStringValue = "09/05/2012" };
                    respondent.surveyQuestionResponseList.Add(responseqn6);
                    survey.surveyQuestionList.ElementAt(6).surveyQuestionResponseList.Add(responseqn6);
                    var responseqn7 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 1 };
                    respondent.surveyQuestionResponseList.Add(responseqn7);
                    survey.surveyQuestionList.ElementAt(7).surveyQuestionResponseList.Add(responseqn7);

                    survey.AddRespondent(respondent);

                    var respondent1 = new Entities.Respondent { respondentIPAddress = "127.0.0.1", respondentSessionID = "randomid1" };
                    var responseqn10 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 2 };
                    respondent1.surveyQuestionResponseList.Add(responseqn10);
                    survey.surveyQuestionList.ElementAt(0).surveyQuestionResponseList.Add(responseqn10);
                    var responseqn11 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 3 };
                    respondent1.surveyQuestionResponseList.Add(responseqn11);
                    survey.surveyQuestionList.ElementAt(1).surveyQuestionResponseList.Add(responseqn11);
                    var responseqn12 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 4 };
                    respondent1.surveyQuestionResponseList.Add(responseqn12);
                    survey.surveyQuestionList.ElementAt(2).surveyQuestionResponseList.Add(responseqn12);
                    var responseqn130 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 0 };
                    var responseqn131 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 5 };
                    var responseqn132 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 6 };
                    respondent1.surveyQuestionResponseList.Add(responseqn130);
                    respondent1.surveyQuestionResponseList.Add(responseqn131);
                    respondent1.surveyQuestionResponseList.Add(responseqn132);
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionResponseList.Add(responseqn130);
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionResponseList.Add(responseqn131);
                    survey.surveyQuestionList.ElementAt(3).surveyQuestionResponseList.Add(responseqn132);
                    var responseqn14 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 2, responseStringValue = "10" };
                    respondent1.surveyQuestionResponseList.Add(responseqn14);
                    survey.surveyQuestionList.ElementAt(4).surveyQuestionResponseList.Add(responseqn14);
                    var responseqn15 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 2, responseIntegerValue = 3, responseStringValue = "43" };
                    respondent1.surveyQuestionResponseList.Add(responseqn15);
                    survey.surveyQuestionList.ElementAt(5).surveyQuestionResponseList.Add(responseqn15);
                    var responseqn16 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 2, responseStringValue = "09/05/2012" };
                    respondent1.surveyQuestionResponseList.Add(responseqn16);
                    survey.surveyQuestionList.ElementAt(6).surveyQuestionResponseList.Add(responseqn16);
                    var responseqn17 = new Entities.SurveyQuestionResponse { responseIsAnswered = true, responseType = 1, responseIntegerValue = 0 };
                    respondent1.surveyQuestionResponseList.Add(responseqn17);
                    survey.surveyQuestionList.ElementAt(7).surveyQuestionResponseList.Add(responseqn17);

                    survey.AddRespondent(respondent1);

                    user.AddSurvey(survey);
                    session.SaveOrUpdate(user);
                    transaction.Commit();

                }

            }
            //Context.Response.Write(js.Serialize(survey));
        }
        public void FBLogin(string FBID, string firstName, string lastName, string email)
        {
            using (var session = FluentNHibernateConfiguration.InitFactory.sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    //JObject jsonObject = JObject.Parse(jsonString);
                    JavaScriptSerializer js = new JavaScriptSerializer();

                    var member = Member.GetByFBID(session, FBID);
                    if (member == null)
                    {
                        var user = new Entities.Member
                        {
                            memberFirstName = firstName,
                            memberLastName = lastName,
                            userName = FBID,
                            memberPassword = FBID,
                            memberEmail = email,
                            memberFBID = FBID
                        };
                        user.memberHash = util.UtilityMethods.CalculateMD5Hash(user.userName + DateTime.Now.ToShortTimeString());
                        Context.Response.Write(js.Serialize(new Response3 { LogIn = 1, twocubeSSO = user.memberHash }));
                        session.Save(user);
                        transaction.Commit();
                        //Context.Response.Write(js.Serialize(new Response3 { LogIn = 0 }));
                    }
                    else
                    {
                        //DateTime dt = new DateTime();
                        member.memberHash = util.UtilityMethods.CalculateMD5Hash(member.userName + DateTime.Now.ToShortTimeString());
                        Context.Response.Write(js.Serialize(new Response3 { LogIn = 1, twocubeSSO = member.memberHash }));
                        session.SaveOrUpdate(member);
                        transaction.Commit();
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //rTxtLog.Text = string.Empty;
            Cursor.Current = Cursors.WaitCursor;

            string connString = string.Empty;
            string status     = "Status: \t";
            string serror     = "Error:  \t";
            string swaring    = "Waring: \t";

            BusinessLayer.BLLCRM.MemberBLL memberBLL = new BusinessLayer.BLLCRM.MemberBLL();
            if (validation())
            {
                rTxtLog.AppendText(status + "Opening Excel File...\n");
                rTxtLog.AppendText(status + "File is opened, waiting for welcome message...\n");

                DataTable dtExcel      = VVPosM1.BusinessLayer.BLLCRM.ImportMember.ReadExcelFile(filepath);
                Boolean   bFlagUpdate  = false;
                int       iRowError    = 0;
                int       iRowSuccess  = 0;
                int       iTotalRecord = 0;

                //Set Column Label
                string   strMemberCode  = txtMemberCode.Text.Trim();
                string[] strFullName    = txtMemerName.Text.Split(';');
                string   strChucDanh    = txtChucDanh.Text.Trim();
                string   strCompanyName = txtCompanyName.Text.Trim();
                string   strAddress     = txtAddress.Text.Trim();
                string[] strEmails      = txtCompanyEmail.Text.Split(';');
                string   strPhone       = txtPhoneNumber.Text;
                string   strmPhone      = txtMobilePhone.Text;
                string   strWebsite     = txtWebsite.Text;
                string   strTaxCode     = txtTaxCode.Text;
                string[] strNotes       = txtDescription.Text.Split(';');
                string   strBirthDay    = txtBirthday.Text;

                int iTemps = -1;

                string strTemp = string.Empty;
                int    iBegin  = (int.Parse(txtFirstLine.Text) - 1) > 0 ? int.Parse(txtFirstLine.Text) - 1 : 0;


                for (int iCount = iBegin; iCount < int.Parse(txtEndLine.Text); iCount++)
                {
                    if (iCount >= dtExcel.Rows.Count)
                    {
                        break;
                    }

                    DataRow         dr         = dtExcel.Rows[iCount];
                    Entities.Member member     = new Entities.Member();
                    int             iLineError = 0;

                    //Count total record
                    iTotalRecord++;

                    rTxtLog.AppendText("Reading line: " + iTotalRecord.ToString() + "\n");

                    //Get Col MemberCode
                    if (chBAutoID.Checked == true)
                    {
                        try
                        {
                            member.MemberCode = BusinessLayer.BLLCRM.ImportMember.GetAutoMemberCode();
                        }
                        catch (Exception)
                        {
                            rTxtLog.AppendText(swaring + "Customer code is null.\n");
                            iLineError++;
                        }
                    }
                    else
                    {
                        iTemps = BusinessLayer.BLLCRM.ImportMember.returnCellName(strMemberCode);

                        try
                        {
                            if (dr[iTemps].ToString() != string.Empty)
                            {
                                member.MemberCode = dr[iTemps].ToString();

                                //Check exists
                                if (chBOveride.Checked == true)
                                {
                                    if (memberBLL.CheckMemberCodeExist(member.MemberCode))
                                    {
                                        if (memberBLL.getMemberId(member.MemberCode) != string.Empty)
                                        {
                                            member.MemberId = memberBLL.getMemberId(member.MemberCode);
                                            bFlagUpdate     = true;
                                        }
                                        else
                                        {
                                            rTxtLog.AppendText(serror + "Customer ID is not getted. SQL command error.\n");
                                            iLineError++;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                rTxtLog.AppendText(serror + "Customer code is null.\n");
                                iLineError++;
                            }
                        }
                        catch (Exception)
                        {
                            rTxtLog.AppendText(serror + "Customer code is null.\n");
                            iLineError++;
                        }
                    }


                    //Get Fullname
                    strTemp = string.Empty;
                    if (strFullName.Length > 0)
                    {
                        foreach (var item in strFullName)
                        {
                            if (item != "")
                            {
                                iTemps = BusinessLayer.BLLCRM.ImportMember.returnCellName(item.Trim());
                                try
                                {
                                    strTemp += dr[iTemps].ToString() + " ";
                                }
                                catch (Exception)
                                {
                                    rTxtLog.AppendText(serror + "Column " + item + ": data not found.\n");
                                    //iLineError++;
                                }
                            }
                        }
                    }

                    member.MemberName = strTemp.Trim();


                    //Get Chuc Danh

                    if (strChucDanh != string.Empty)
                    {
                        iTemps = BusinessLayer.BLLCRM.ImportMember.returnCellName(strChucDanh);

                        try
                        {
                            member.Regency = dr[iTemps].ToString();
                        }
                        catch (Exception)
                        {
                            member.Regency = string.Empty;
                            rTxtLog.AppendText(serror + "Column " + strChucDanh + ": data not found.\n");
                        }
                    }
                    else
                    {
                        member.Regency = string.Empty;
                    }


                    //Get Company name
                    if (strCompanyName != string.Empty)
                    {
                        iTemps = BusinessLayer.BLLCRM.ImportMember.returnCellName(strCompanyName);
                        try
                        {
                            member.CompanyName = dr[iTemps].ToString();
                        }
                        catch (Exception)
                        {
                            member.CompanyName = string.Empty;
                            rTxtLog.AppendText(serror + "Column " + strCompanyName + ": data not found.\n");
                        }
                    }
                    else
                    {
                        member.CompanyName = string.Empty;
                    }

                    //Check Member name or Company name is not null
                    if (member.MemberName == string.Empty && member.CompanyName == string.Empty)
                    {
                        iLineError++;
                        rTxtLog.AppendText(serror + "Customer name or company name are not null.\n");
                    }
                    else
                    {
                        if (member.MemberName == string.Empty)
                        {
                            rTxtLog.AppendText(swaring + "Customer name is null\n");
                        }

                        if (member.CompanyName == string.Empty)
                        {
                            rTxtLog.AppendText(swaring + "Company name is null\n");
                        }
                    }

                    //Get Address
                    if (strAddress != string.Empty)
                    {
                        iTemps = BusinessLayer.BLLCRM.ImportMember.returnCellName(strAddress);

                        try
                        {
                            member.Address = dr[iTemps].ToString();
                        }
                        catch (Exception)
                        {
                            member.Address = string.Empty;
                            rTxtLog.AppendText(serror + "Column " + strAddress + ": data not found.\n");
                        }
                    }
                    else
                    {
                        member.Address = string.Empty;
                    }


                    //Get Email
                    strTemp = string.Empty;
                    int iTemp = 1;

                    if (strEmails.Length > 0)
                    {
                        foreach (var item in strEmails)
                        {
                            if (item != "")
                            {
                                try
                                {
                                    iTemps = BusinessLayer.BLLCRM.ImportMember.returnCellName(item.Trim());
                                    if (Common.Validation.ValidateEmail(dr[iTemps].ToString()))
                                    {
                                        strTemp += dr[iTemps].ToString() + ";";
                                    }
                                    else
                                    {
                                        rTxtLog.AppendText(swaring + "Email " + iTemp + ": incorrect email format.\n");
                                        iTemp++;
                                        //iLineError++;
                                    }
                                }
                                catch (Exception)
                                {
                                    rTxtLog.AppendText(swaring + "Column " + item + ": data not found.\n");
                                    //iLineError++;
                                }
                            }
                        }
                    }

                    char[] charsToTrim = { ',', '.', ' ', ';' };
                    strTemp             = strTemp.Trim();
                    strTemp             = strTemp.TrimEnd(charsToTrim);
                    member.CompanyEmail = strTemp;
                    member.Email        = strTemp;

                    //Get Phone number
                    if (strPhone != string.Empty)
                    {
                        iTemps = ImportMember.returnCellName(strPhone);
                        try
                        {
                            member.PhoneNumber = dr[iTemps].ToString();
                        }
                        catch (Exception)
                        {
                            member.PhoneNumber = string.Empty;
                            rTxtLog.AppendText(swaring + "Column " + strPhone + ": data not found.\n");
                        }
                    }
                    else
                    {
                        member.PhoneNumber = string.Empty;
                    }


                    //Get mobile phone
                    if (strmPhone != string.Empty)
                    {
                        iTemps = ImportMember.returnCellName(strmPhone);
                        try
                        {
                            member.MobilePhone = dr[iTemps].ToString();
                        }
                        catch (Exception)
                        {
                            member.MobilePhone = string.Empty;
                            rTxtLog.AppendText(swaring + "Column " + strmPhone + ": data not found.\n");
                        }
                    }
                    else
                    {
                        member.MobilePhone = string.Empty;
                    }

                    //Get Tax code
                    if (strTaxCode != string.Empty)
                    {
                        iTemps = ImportMember.returnCellName(strTaxCode);
                        try
                        {
                            member.TaxCode = dr[iTemps].ToString();
                        }
                        catch (Exception)
                        {
                            member.TaxCode = string.Empty;
                            rTxtLog.AppendText(swaring + "Column " + strTaxCode + ": data not found.\n");
                        }
                    }
                    else
                    {
                        member.TaxCode = string.Empty;
                    }


                    //Get website
                    if (strWebsite != string.Empty)
                    {
                        iTemps = ImportMember.returnCellName(strWebsite);
                        try
                        {
                            if (Common.Validation.ValidateWebsite(dr[iTemps].ToString()))
                            {
                                member.Website = dr[iTemps].ToString();
                            }
                            else
                            {
                                rTxtLog.AppendText(swaring + "Website incorrect format.\n");
                            }
                        }
                        catch (Exception)
                        {
                            member.Website = string.Empty;
                            rTxtLog.AppendText(swaring + "Column " + strWebsite + ": data not found.\n");
                        }
                    }
                    else
                    {
                        member.Website = string.Empty;
                    }



                    strTemp = string.Empty;
                    iTemp   = 1;


                    if (strNotes.Length > 0)
                    {
                        foreach (var item in strNotes)
                        {
                            iTemps = ImportMember.returnCellName(item.Trim());
                            try
                            {
                                strTemp += (dr[iTemps].ToString() + "'\r\n'");
                            }
                            catch (Exception)
                            {
                                rTxtLog.AppendText(swaring + "Column " + item + ": data not found.\n");
                            }
                        }
                    }


                    member.Description = strTemp;

                    //Get birthday
                    if (strBirthDay != string.Empty)
                    {
                        iTemps = ImportMember.returnCellName(strBirthDay);
                        try
                        {
                            member.birthDay  = true;
                            member.BirthDate = DateTime.ParseExact(dr[iTemps].ToString(), cbbDatetimeFormat.SelectedItem.ToString(), System.Globalization.DateTimeFormatInfo.CurrentInfo, System.Globalization.DateTimeStyles.None);         //Common.Utility.StringToDateTimeVer2(dr[iTemps].ToString());
                        }
                        catch (Exception)
                        {
                            member.birthDay = false;
                            //member.BirthDate =  DateTime.Now;
                            rTxtLog.AppendText(swaring + "Column " + strBirthDay + ": data not found.\n");
                        }
                    }
                    else
                    {
                        member.birthDay  = false;
                        member.BirthDate = DateTime.Now;
                    }

                    //creator
                    member.Creator.EmployeeId = Program.employee1.EmployeeId;
                    member.Curator.EmployeeId = cbbCreator.SelectedValue.ToString();

                    //Get Country ID OT
                    member.Country.CountryId = countryID;

                    //Member Type
                    List <Entities.MemberType> lstMemberTypeName = new List <Entities.MemberType>();
                    MemberTypeBLL       mt  = new MemberTypeBLL();
                    DataTable           dt  = mt.GetLists();
                    Entities.MemberType mbt = new Entities.MemberType();

                    int iFlag = 0;
                    foreach (DataRow drtemp in dt.Rows)
                    {
                        if (drtemp["MemberTypeCode"].ToString().Equals("OT"))
                        {
                            mbt.MemberTypeId    = int.Parse(drtemp["MemberTypeId"].ToString());
                            mbt.MemberTypeName  = drtemp["MemberTypeName"].ToString();
                            mbt.MemberTypeName2 = drtemp["MemberTypeName2"].ToString();
                            mbt.MemberTypeName3 = drtemp["MemberTypeName3"].ToString();
                            mbt.MemberTypeCode  = drtemp["MemberTypeCode"].ToString();
                            iFlag = 1;
                            break;
                        }
                    }

                    if (iFlag == 0)
                    {
                        mbt.MemberTypeId    = int.Parse(dt.Rows[0]["MemberTypeId"].ToString());
                        mbt.MemberTypeName  = dt.Rows[0]["MemberTypeName"].ToString();
                        mbt.MemberTypeName2 = dt.Rows[0]["MemberTypeName2"].ToString();
                        mbt.MemberTypeName3 = dt.Rows[0]["MemberTypeName3"].ToString();
                        mbt.MemberTypeCode  = dt.Rows[0]["MemberTypeCode"].ToString();
                    }

                    lstMemberTypeName.Add(mbt);

                    member.List_MemberType = lstMemberTypeName;

                    //member.Email        = string.Empty;

                    member.TotalScore          = 0;
                    member.CurrentScore        = 0;
                    member.NumberOfVissits     = 0;
                    member.IsLock              = 0;
                    member.CallName.CallNameID = CallNameID;
                    //Lastest Date
                    member.LastestDate = DateTime.Now;
                    //Created date
                    member.CreatedDate = DateTime.Now;
                    //Updated date
                    member.UpdatedDate = DateTime.Now;

                    if (chBOveride.Checked == true)
                    {
                        if (bFlagUpdate == true)
                        {
                            try
                            {
                                memberBLL.Edit(member);
                            }
                            catch (Exception)
                            {
                                rTxtLog.AppendText(status + "Row " + iTotalRecord.ToString() + " is not update.\n");
                                iLineError++;
                            }
                        }
                        else
                        {
                            try
                            {
                                if (!memberBLL.CheckMemberCodeExist(member.MemberCode))
                                {
                                    memberBLL.Add(member);
                                }
                                else
                                {
                                    rTxtLog.AppendText(status + "Row " + iTotalRecord.ToString() + ": member code is exists.\n");
                                    iLineError++;
                                }
                            }
                            catch (Exception)
                            {
                                rTxtLog.AppendText(status + "Row " + iTotalRecord.ToString() + " is not insert.\n");
                                iLineError++;
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            if (!memberBLL.CheckMemberCodeExist(member.MemberCode))
                            {
                                memberBLL.Add(member);
                            }
                            else
                            {
                                rTxtLog.AppendText(status + "Row " + iTotalRecord.ToString() + ": member code is exists.\n");
                                iLineError++;
                            }
                        }
                        catch (Exception)
                        {
                            rTxtLog.AppendText(status + "Row " + iTotalRecord.ToString() + " is not insert.\n");
                            iLineError++;
                        }
                    }


                    if (iLineError == 0)
                    {
                        rTxtLog.AppendText(status + "Row " + iTotalRecord.ToString() + " is inserted database.\n");
                        iRowSuccess++;
                    }
                    else
                    {
                        rTxtLog.AppendText(status + "Row " + iTotalRecord.ToString() + " is error.\n");
                        iRowError++;
                    }
                    iLineError = 0;
                }

                rTxtLog.AppendText(status + "Closing Excel File...\n");
                rTxtLog.AppendText(status + "File is closed\n");
                rTxtLog.AppendText(iRowError + " error record. " + iRowSuccess + " success record.\n");
                rTxtLog.AppendText("Total " + iTotalRecord.ToString() + " record.\n");

                CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM629"),
                                                                 Common.clsLanguages.GetResource("CRM11"),
                                                                 Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                 Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK);
            }
        }