Example #1
0
        private string BuildCustomerInfo(Customer c)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("公司:" + c.company);
            builder.AppendLine("国家:" + c.country);
            builder.AppendLine("网站:" + c.site);
            builder.AppendLine("地址:" + c.addr);
            builder.AppendLine("姓名:" + c.name);
            builder.AppendLine("Skype:" + c.skype);
            builder.AppendLine("邮箱:" + c.email);
            builder.AppendLine("手机:" + c.mobile);
            builder.AppendLine("电话:" + c.phone);
            builder.AppendLine("浏览:" + c.browse.ToString());
            builder.AppendLine("询盘:" + c.inquiry.ToString());

            builder.AppendLine("首次:" + c.create_on.ToShortDateString());
            builder.AppendLine("最近:" + c.update_on.ToShortDateString());
            builder.AppendLine("下次:" + GetNext(c).ToShortDateString());
            builder.AppendLine("状态:" + m_states[c.state_id].ToString());
            builder.AppendLine("剩余:" + c.count.ToString());

            if (!string.IsNullOrEmpty(c.country))
            {
                Country country = GetCountry(c.country);
                if (country != null)
                {
                    builder.AppendLine("===========国家===========");
                    builder.AppendLine(BuildCountryInfo(country));
                }
            }

            builder.AppendLine("===========备注===========");
            builder.AppendLine(c.note);
            return builder.ToString();
        }
Example #2
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (m_customer == null)
            {
                m_customer = new Customer();
                m_customer.create_on = m_customer.update_on = DateTime.Today;
            }

            //TODO: check input
            m_customer.company = textBoxCompany.Text.Trim();

            if (!CheckInput(m_customer.company, "公司"))
            {
                return;
            }

            m_customer.country = comboBoxCountry.Text.Trim();

            m_customer.site = textBoxSite.Text.Trim();

            m_customer.addr = textBoxAddr.Text.Trim();

            m_customer.phone = textBoxPhone.Text.Trim();

            m_customer.name = textBoxName.Text.Trim();

            if (!CheckInput(m_customer.name, "姓名"))
            {
                return;
            }

            m_customer.skype = textBoxSkype.Text.Trim();

            m_customer.mobile = textBoxMobile.Text.Trim();
            m_customer.email = textBoxEmail.Text.Trim();

            string re = @"^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";
            bool match = Regex.IsMatch(m_customer.email,re);
            if (!match)
            {
                Popup.Warn(string.Format("邮箱地址无效!"));
                return;
            }

            m_customer.inquiry = (int)numericUpDownInquiry.Value;
            m_customer.browse  = (int)numericUpDownBrowse.Value;

            m_customer.create_on = dateTimePickerCreateOn.Value;
            m_customer.update_on = dateTimePickerUpdateOn.Value;

            m_customer.note = richTextBoxNote.Text.Trim();
            m_customer.state_id = comboBoxState.SelectedIndex + 1;
            m_customer.count = (int)numericUpDownCount.Value;

            m_customer.count = (int)numericUpDownCount.Value;

            DialogResult = DialogResult.OK;
        }
Example #3
0
 private void UpdateListViewItem(Customer obj, ListViewItem item)
 {
     item.SubItems.Clear();
     item.Text = obj.company;
     item.SubItems.Add(obj.country);
     State state = m_states[obj.state_id];
     item.SubItems.Add(state.ToString());
     item.SubItems.Add(obj.name);
     item.SubItems.Add(obj.email);
     item.SubItems.Add(obj.update_on.ToShortDateString());
     item.SubItems.Add(GetNext(obj).ToShortDateString());
     item.SubItems.Add(obj.create_on.ToShortDateString());
     item.Checked = checkBoxAll.Checked;
     item.BackColor = m_colors[obj.state_id];
     item.Tag = obj;
 }
Example #4
0
 private string RenderEmail(Customer customer, State state)
 {
     string path = string.Format("template/{0}.txt", state.name);
     string content = File.ReadAllText(path);
     StringTemplate tmpl = new StringTemplate(content);
     tmpl.SetAttribute("NAME", customer.name);
     tmpl.SetAttribute("DATE", customer.update_on.ToShortDateString());
     return tmpl.ToString();
 }
Example #5
0
 private DateTime GetNext(Customer obj)
 {
     State state = m_states[obj.state_id];
     DateTime next = obj.update_on.AddDays(state.period);
     return next;
 }
Example #6
0
 private ListViewItem CreateListViewItem(Customer c)
 {
     ListViewItem item = new ListViewItem();
     UpdateListViewItem(c,item);
     return item;
 }
Example #7
0
 public void SetCustomer(Customer customer)
 {
     m_customer = customer;
 }