Beispiel #1
0
        private ResultsWithCount <CustomerDto> QueryCustomers()
        {
            txtName.Text   = txtName.Text.Trim();
            txtMobile.Text = txtMobile.Text.Trim();
            Int32?projectId = null;

            if (cmbProjects.SelectedValue != null)
            {
                projectId = Convert.ToInt32(cmbProjects.SelectedValue.ToString());
                if (projectId == -1)
                {
                    projectId = null;
                }
            }
            Int32?source = null;

            if (cmbCustomerSources.SelectedValue != null)
            {
                source = Convert.ToInt32(cmbCustomerSources.SelectedValue.ToString());
                if (source == -1)
                {
                    source = null;
                }
            }
            ResultsWithCount <CustomerDto> customers = CustomerService.QueryUnAssignedCustomers(Global.USER_TOKEN,
                                                                                                pager.PageIndex, pager.PageSize, projectId,
                                                                                                source, txtName.Text, txtMobile.Text);

            return(customers);
        }
Beispiel #2
0
        private ResultsWithCount <CustomerDto> QueryCustomers()
        {
            txtName.Text   = txtName.Text.Trim();
            txtMobile.Text = txtMobile.Text.Trim();
            String provinceId = cmbProvinces.SelectedValue != null?cmbProvinces.SelectedValue.ToString() : String.Empty;

            String cityId = cmbCities.SelectedValue != null?cmbCities.SelectedValue.ToString() : String.Empty;

            String countyId = cmbCounties.SelectedValue != null?cmbCounties.SelectedValue.ToString() : String.Empty;

            Int32?projectId = null;

            if (cmbProjects.SelectedValue != null)
            {
                projectId = Convert.ToInt32(cmbProjects.SelectedValue.ToString());
                if (projectId == -1)
                {
                    projectId = null;
                }
            }
            Int32?status = null;

            if (cmbStatus.SelectedValue != null)
            {
                status = Convert.ToInt32(cmbStatus.SelectedValue.ToString());
                if (status == -1)
                {
                    status = null;
                }
            }
            Int32?source = null;

            if (cmbCustomerSources.SelectedValue != null)
            {
                source = Convert.ToInt32(cmbCustomerSources.SelectedValue.ToString());
                if (source == -1)
                {
                    source = null;
                }
            }
            Int32?type = null;

            if (cmbCustomerTypes.SelectedValue != null)
            {
                type = Convert.ToInt32(cmbCustomerTypes.SelectedValue.ToString());
                if (type == -1)
                {
                    type = null;
                }
            }
            ResultsWithCount <CustomerDto> customers = CustomerService.QueryCustomersFromPublic(Global.USER_TOKEN, pager.PageIndex, pager.PageSize, projectId,
                                                                                                status, source, type, txtName.Text, txtMobile.Text, provinceId, cityId, countyId);

            return(customers);
        }
Beispiel #3
0
 private void Pager_OnPageChanged(object sender, EventArgs e)
 {
     try
     {
         ResultsWithCount <UserDto> users = QueryUsers();
         Refresh(users.getResults());
     }
     catch (BusinessException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #4
0
        private void FormSelectUser_Load(object sender, EventArgs e)
        {
            ResultsWithCount <UserDto> users = UserService.QueryUsers(Global.USER_TOKEN, 1, Int32.MaxValue, null, null, null, null);

            foreach (UserDto user in users.getResults())
            {
                ListViewItem lvi = new ListViewItem(user.name);
                lvi.SubItems.Add(user.mobile);
                lvi.Tag = user;
                lvUsers.Items.Add(lvi);
            }
        }
Beispiel #5
0
 private void Pager_OnPageChanged(object sender, EventArgs e)
 {
     try
     {
         customers = QueryCustomers();
         //将数据绑定到ListView
         BindingDatas(customers);
     }
     catch (BusinessException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #6
0
        private void BindingDatas(ResultsWithCount <CustomerDto> customers)
        {
            lvClients.BeginUpdate();
            lvClients.Items.Clear();
            int i = 1 + (pager.PageSize) * (pager.PageIndex - 1);//计算序号

            foreach (CustomerDto customer in customers.getResults())
            {
                ListViewItem lvi = new ListViewItem();
                BindingData(lvi, i, customer);
                lvClients.Items.Add(lvi);
                i++;
            }
            lvClients.EndUpdate();
        }
Beispiel #7
0
        private void BindingDatas(ResultsWithCount <CustomerDto> customers)
        {
            if (lvClients.Items.Count > 0)
            {
                lvClients.Items.Clear();
            }
            lvClients.BeginUpdate();
            int i = 1 + (pager.PageSize) * (pager.PageIndex - 1);//计算序号

            foreach (CustomerDto customer in customers.getResults())
            {
                BindingData(i, customer);
                i++;
            }
            lvClients.EndUpdate();
        }
Beispiel #8
0
 private void ButReset_Click(object sender, EventArgs e)
 {
     txtMobile.Text                   = txtName.Text = string.Empty;
     cmbProjects.SelectedIndex        = 0;
     cmbCustomerTypes.SelectedIndex   = 0;
     cmbCustomerSources.SelectedIndex = 0;
     cmbProvinces.SelectedIndex       = 0;
     lvClients.Items.Clear();
     txtFollowUserName.Tag    = null;
     txtFollowUserName.Text   = "";
     cbLeaveWordsTime.Checked = false;
     pager.Reset();
     txtName.Focus();
     txtFirstOwnerName.Tag  = null;
     txtFirstOwnerName.Text = "";
     customers = new ResultsWithCount <CustomerDto>();
 }
Beispiel #9
0
 private void Query()
 {
     try
     {
         //查询符合条件的记录
         customers       = QueryCustomers();
         pager.PageIndex = 1;
         pager.DrawControl((int)customers.getCount());
         //将数据绑定到ListView
         BindingDatas(customers);
         pager.NeedExcuteQuery = true;
     }
     catch (BusinessException ex)
     {
         MessageBox.Show("查询失败:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #10
0
 public void Query()
 {
     try
     {
         //根据条件查询用户
         ResultsWithCount <UserDto> users = QueryUsers();
         //获取符合条件的用户总数量后修改Pager的相关属性
         pager.PageIndex = 1;
         pager.DrawControl((int)users.getCount());
         //更新用户列表
         Refresh(users.getResults());
         pager.NeedExcuteQuery = true;
     }
     catch (BusinessException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #11
0
        public static ResultsWithCount <UserDto> QueryUsers(String token,
                                                            Int32?pageNum,
                                                            Int32?pageSize,
                                                            String name,
                                                            String mobile,
                                                            Int32?gender,
                                                            Boolean?active)
        {
            RestClient rc      = new RestClient();
            var        request = new RestRequest(GlobalConfig.USERS, Method.GET);

            request.AddHeader(GlobalConfig.AUTHORIZATION, token);
            if (pageNum != null)
            {
                request.AddParameter("page", pageNum);
            }
            if (pageSize != null)
            {
                request.AddParameter("page_size", pageSize);
            }
            if (gender != null)
            {
                request.AddParameter("gender", gender);
            }
            if (active != null)
            {
                request.AddParameter("active", active);
            }
            if (!String.IsNullOrEmpty(mobile))
            {
                request.AddParameter("mobile", mobile);
            }
            if (!String.IsNullOrEmpty(name))
            {
                request.AddParameter("name", name);
            }
            try
            {
                var response = rc.Get(request);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var customers = rc.Deserialize <List <UserDto> >(response);
                    return(ResultsWithCount <UserDto> .of(customers.Data, GetTotalCountFromResponseHeaders(response)));
                }
                else if (response.StatusCode == 0)
                {
                    throw new BusinessException("请检查网络");
                }
                else
                {
                    var res             = rc.Deserialize <CustomException>(response);
                    var customException = res.Data;
                    throw new BusinessException(customException.message);
                }
            }
            catch (BusinessException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new BusinessException(ex.Message);
            }
        }
Beispiel #12
0
        /// <summary>
        /// 根據條件查詢客戶信息(公海)
        /// </summary>
        /// <param name="token"></param>
        /// <param name="pageNum"></param>
        /// <param name="pageSize"></param>
        /// <param name="status"></param>
        /// <param name="source"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        /// <param name="mobile"></param>
        /// <param name="provinceId"></param>
        /// <param name="cityId"></param>
        /// <param name="countyId"></param>
        /// <returns></returns>
        public static ResultsWithCount <CustomerDto> QueryUnAssignedCustomers(String token,
                                                                              Int32?pageNum,
                                                                              Int32?pageSize,
                                                                              Int32?projectId,
                                                                              Int32?source,
                                                                              String name,
                                                                              String mobile)
        {
            RestClient rc      = new RestClient();
            var        request = new RestRequest(GlobalConfig.CUSTOMERS_UNASSIGNED, Method.GET);

            request.AddHeader(GlobalConfig.AUTHORIZATION, token);
            if (pageNum != null)
            {
                request.AddParameter("page", pageNum);
            }
            if (projectId != null)
            {
                request.AddParameter("project_id", projectId);
            }
            if (pageSize != null)
            {
                request.AddParameter("page_size", pageSize);
            }
            if (source != null)
            {
                request.AddParameter("source", source);
            }
            if (!String.IsNullOrEmpty(mobile))
            {
                request.AddParameter("mobile", mobile);
            }
            if (!String.IsNullOrEmpty(name))
            {
                request.AddParameter("name", name);
            }
            try
            {
                var response = rc.Get(request);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var customers = rc.Deserialize <List <CustomerDto> >(response);
                    return(ResultsWithCount <CustomerDto> .of(customers.Data, GetTotalCountFromResponseHeaders(response)));
                }
                else if (response.StatusCode == 0)
                {
                    throw new BusinessException("请检查网络");
                }
                else
                {
                    var res             = rc.Deserialize <CustomException>(response);
                    var customException = res.Data;
                    throw new BusinessException(customException.message);
                }
            }
            catch (BusinessException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new BusinessException(ex.Message);
            }
        }
Beispiel #13
0
        /// <summary>
        /// 根据条件查询我的客戶信息
        /// </summary>
        /// <param name="token"></param>
        /// <param name="pageNum"></param>
        /// <param name="pageSize"></param>
        /// <param name="status"></param>
        /// <param name="source"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        /// <param name="mobile"></param>
        /// <param name="provinceId"></param>
        /// <param name="cityId"></param>
        /// <param name="countyId"></param>
        /// <returns></returns>
        public static ResultsWithCount <CustomerDto> QueryMyCustomers(String token,
                                                                      Int32?pageNum,
                                                                      Int32?pageSize,
                                                                      Int32?projectId,
                                                                      Int32?status,
                                                                      Int32?source,
                                                                      Int32?type,
                                                                      String name,
                                                                      String mobile,
                                                                      String provinceId,
                                                                      String cityId,
                                                                      String countyId,
                                                                      String leaveWordsTimeBegin,
                                                                      String leaveWordsTimeEnd,
                                                                      String nextFollowTimeStart,
                                                                      String nextFollowTimeEnd)
        {
            RestClient rc      = new RestClient();
            var        request = new RestRequest(GlobalConfig.MY_CUSTOMERS, Method.GET);

            request.AddHeader(GlobalConfig.AUTHORIZATION, token);
            if (pageNum != null)
            {
                request.AddParameter("page", pageNum);
            }
            if (projectId != null)
            {
                request.AddParameter("project_id", projectId);
            }
            if (pageSize != null)
            {
                request.AddParameter("page_size", pageSize);
            }
            if (status != null)
            {
                request.AddParameter("status", status);
            }
            if (source != null)
            {
                request.AddParameter("source", source);
            }
            if (type != null)
            {
                request.AddParameter("type", type);
            }
            if (!String.IsNullOrEmpty(mobile))
            {
                request.AddParameter("mobile", mobile);
            }
            if (!String.IsNullOrEmpty(provinceId))
            {
                request.AddParameter("province_id", provinceId);
            }
            if (!String.IsNullOrEmpty(cityId))
            {
                request.AddParameter("city_id", cityId);
            }
            if (!String.IsNullOrEmpty(countyId))
            {
                request.AddParameter("county_id", countyId);
            }
            if (!String.IsNullOrEmpty(name))
            {
                request.AddParameter("name", name);
            }
            if (!String.IsNullOrEmpty(leaveWordsTimeBegin))
            {
                request.AddParameter("leave_words_begin", leaveWordsTimeBegin);
            }
            if (!String.IsNullOrEmpty(nextFollowTimeStart))
            {
                request.AddParameter("next_follow_time_start", nextFollowTimeStart);
            }
            if (!String.IsNullOrEmpty(nextFollowTimeEnd))
            {
                request.AddParameter("next_follow_time_end", nextFollowTimeEnd);
            }
            if (!String.IsNullOrEmpty(leaveWordsTimeEnd))
            {
                request.AddParameter("leave_words_end", leaveWordsTimeEnd);
            }
            try
            {
                var response = rc.Get(request);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var customers = rc.Deserialize <List <CustomerDto> >(response);
                    return(ResultsWithCount <CustomerDto> .of(customers.Data, GetTotalCountFromResponseHeaders(response)));
                }
                else if (response.StatusCode == 0)
                {
                    throw new BusinessException("请检查网络");
                }
                else
                {
                    var res             = rc.Deserialize <CustomException>(response);
                    var customException = res.Data;
                    throw new BusinessException(customException.message);
                }
            }
            catch (BusinessException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new BusinessException(ex.Message);
            }
        }
Beispiel #14
0
        private ResultsWithCount <CustomerDto> QueryCustomers()
        {
            txtName.Text   = txtName.Text.Trim();
            txtMobile.Text = txtMobile.Text.Trim();
            String provinceId = cmbProvinces.SelectedValue != null?cmbProvinces.SelectedValue.ToString() : String.Empty;

            String cityId = cmbCities.SelectedValue != null?cmbCities.SelectedValue.ToString() : String.Empty;

            String countyId = cmbCounties.SelectedValue != null?cmbCounties.SelectedValue.ToString() : String.Empty;

            Int32?projectId = null;

            if (cmbProjects.SelectedValue != null)
            {
                projectId = Convert.ToInt32(cmbProjects.SelectedValue.ToString());
                if (projectId == -1)
                {
                    projectId = null;
                }
            }
            Int32?status = null;

            if (cmbStatus.SelectedValue != null)
            {
                status = Convert.ToInt32(cmbStatus.SelectedValue.ToString());
                if (status == -1)
                {
                    status = null;
                }
            }
            Int32?source = null;

            if (cmbCustomerSources.SelectedValue != null)
            {
                source = Convert.ToInt32(cmbCustomerSources.SelectedValue.ToString());
                if (source == -1)
                {
                    source = null;
                }
            }
            Int32?type = null;

            if (cmbCustomerTypes.SelectedValue != null)
            {
                type = Convert.ToInt32(cmbCustomerTypes.SelectedValue.ToString());
                if (type == -1)
                {
                    type = null;
                }
            }
            Int64?currentUserId = null;

            if (txtFollowUserName.Tag != null && !String.IsNullOrEmpty(txtFollowUserName.Text))
            {
                currentUserId = Convert.ToInt64(txtFollowUserName.Tag.ToString());
            }
            Int64?firstOwnerId = null;

            if (txtFirstOwnerName.Tag != null && !String.IsNullOrEmpty(txtFirstOwnerName.Text))
            {
                firstOwnerId = Convert.ToInt64(txtFirstOwnerName.Tag.ToString());
            }
            String leaveWordsTimeBegin = null, leaveWordsTimeEnd = null;

            if (cbLeaveWordsTime.Checked)
            {
                if (dtpLeaveWordsTimeBegin.Value.CompareTo(dtpLeaveWordsTimeEnd.Value) > 0)
                {
                    throw new BusinessException("留言范围的截至时间不能早于起始时间");
                }
                leaveWordsTimeBegin = dtpLeaveWordsTimeBegin.Value.ToString("yyyy-MM-dd");
                leaveWordsTimeEnd   = dtpLeaveWordsTimeEnd.Value.ToString("yyyy-MM-dd");
            }
            ResultsWithCount <CustomerDto> customers = CustomerService.QueryCustomers(Global.USER_TOKEN, pager.PageIndex, pager.PageSize,
                                                                                      projectId, status, source, type, txtName.Text, txtMobile.Text, firstOwnerId, currentUserId, provinceId, cityId, countyId, leaveWordsTimeBegin,
                                                                                      leaveWordsTimeEnd);

            return(customers);
        }
Beispiel #15
0
        private ResultsWithCount <CustomerDto> QueryCustomers()
        {
            txtName.Text   = txtName.Text.Trim();
            txtMobile.Text = txtMobile.Text.Trim();
            String provinceId = cmbProvinces.SelectedValue != null?cmbProvinces.SelectedValue.ToString() : String.Empty;

            String cityId = cmbCities.SelectedValue != null?cmbCities.SelectedValue.ToString() : String.Empty;

            String countyId = cmbCounties.SelectedValue != null?cmbCounties.SelectedValue.ToString() : String.Empty;

            //Int32? projectId = null;
            //if (cmbProjects.SelectedValue != null)
            //{
            //    projectId = Convert.ToInt32(cmbProjects.SelectedValue.ToString());
            //    if (projectId == -1)
            //    {
            //        projectId = null;
            //    }
            //}
            Int32?projectId = Global.CURRENT_PROJECT_ID;

            if (projectId.HasValue)
            {
                cmbProjects.SelectedValue = projectId;
            }
            Int32?status = null;

            if (cmbStatus.SelectedValue != null)
            {
                status = Convert.ToInt32(cmbStatus.SelectedValue.ToString());
                if (status == -1)
                {
                    status = null;
                }
            }
            Int32?source = null;

            if (cmbCustomerSources.SelectedValue != null)
            {
                source = Convert.ToInt32(cmbCustomerSources.SelectedValue.ToString());
                if (source == -1)
                {
                    source = null;
                }
            }
            Int32?type = null;

            if (cmbCustomerTypes.SelectedValue != null)
            {
                type = Convert.ToInt32(cmbCustomerTypes.SelectedValue.ToString());
                if (type == -1)
                {
                    type = null;
                }
            }
            //将每页数量改为下拉框内的值
            String leaveWordsTimeBegin = null, leaveWordsTimeEnd = null;

            if (cbLeaveWordsTime.Checked)
            {
                if (dtpLeaveWordsTimeBegin.Value.CompareTo(dtpLeaveWordsTimeEnd.Value) > 0)
                {
                    throw new BusinessException("留言范围的截至时间不能早于起始时间");
                }
                leaveWordsTimeBegin = dtpLeaveWordsTimeBegin.Value.ToString("yyyy-MM-dd");
                leaveWordsTimeEnd   = dtpLeaveWordsTimeEnd.Value.ToString("yyyy-MM-dd");
            }
            String nextFollowTimeBegin = null, nextFollowTimeEnd = null;

            if (cbNextFollowTime.Checked)
            {
                if (dtpNextFollowTimeStart.Value.CompareTo(dtpNextFollowTimeEnd.Value) > 0)
                {
                    throw new BusinessException("下次跟进时间范围截至时间不能早于起始时间");
                }
                nextFollowTimeBegin = dtpNextFollowTimeStart.Value.ToString("yyyy-MM-dd HH:mm");
                nextFollowTimeEnd   = dtpNextFollowTimeEnd.Value.ToString("yyyy-MM-dd HH:mm");
            }
            ResultsWithCount <CustomerDto> customers = CustomerService.QueryMyCustomers(Global.USER_TOKEN, pager.PageIndex, pager.PageSize, projectId,
                                                                                        status, source, type, txtName.Text, txtMobile.Text, provinceId, cityId, countyId, leaveWordsTimeBegin, leaveWordsTimeEnd,
                                                                                        nextFollowTimeBegin, nextFollowTimeEnd);

            return(customers);
        }