/// <summary>
/// 集合添加的控件
/// 涂聚文20150339
/// </summary>
public void AddNewTextBox()
{
Point p = new Point(); Label lb1 = new Label();
this.Controls.Add(lb1);
lb1.Text = "关系名称";
lb1.Top = cLeft * 25;
lb1.RightToLeft = RightToLeft.Yes;
cLeft = cLeft + 1;
flowLayoutPanel1.Controls.Add(lb1); System.Windows.Forms.ComboBox cmb = new ComboBox();
relationshipTypeViewTitile.SetCombox(cmb);
this.Controls.Add(cmb);
cmb.Top = cLeft * 25;
cmb.Size = new System.Drawing.Size(121, 20);
cmb.Left = 2;
flowLayoutPanel1.Controls.Add(cmb); Label lb2 = new Label();
this.Controls.Add(lb2);
lb2.Text = "关系人姓名";
lb2.Top = cLeft * 25;
lb2.RightToLeft = RightToLeft.Yes;
cLeft = cLeft + 1;
flowLayoutPanel1.Controls.Add(lb2); System.Windows.Forms.TextBox txtName = new System.Windows.Forms.TextBox();
this.Controls.Add(txtName);
txtName.Name = "txtName";
txtName.Top = cLeft * 25;
txtName.Left = 200;
txtName.Text = "";// "TextBox" + this.cLeft.ToString();
cLeft = cLeft + 1;
flowLayoutPanel1.Controls.Add(txtName); Label lbtel = new Label();
this.Controls.Add(lbtel);
lbtel.Text = "关系人电话";
lbtel.Top = cLeft * 25;
lbtel.RightToLeft = RightToLeft.Yes;
lbtel.Left = 200;
cLeft = cLeft + 1;
flowLayoutPanel1.Controls.Add(lbtel); System.Windows.Forms.TextBox txtTel = new System.Windows.Forms.TextBox();
this.Controls.Add(txtTel);
txtTel.Name = "txtTel";
txtTel.Top = cLeft * 25;
txtTel.Left = 200;
txtTel.Text = "";// "TextBox" + this.cLeft.ToString();
cLeft = cLeft + 1;
flowLayoutPanel1.Controls.Add(txtTel); Label lb4 = new Label();
this.Controls.Add(lb4);
lb4.Text = "关系人生出日期";
lb4.RightToLeft = RightToLeft.Yes;
lb4.Top = cLeft * 25;
cLeft = cLeft + 1;
flowLayoutPanel1.Controls.Add(lb4); System.Windows.Forms.DateTimePicker dtime = new System.Windows.Forms.DateTimePicker();
dtime.Size = new Size(155, 30);
this.Controls.Add(dtime);
cLeft = cLeft + 1;
flowLayoutPanel1.Controls.Add(dtime); Label lb5 = new Label();
this.Controls.Add(lb5);
lb5.Text = "关系人描述";
lb5.Top = cLeft * 25;
lb5.RightToLeft = RightToLeft.Yes;
cLeft = cLeft + 1;
flowLayoutPanel1.Controls.Add(lb5); System.Windows.Forms.TextBox txtRelationDesc = new System.Windows.Forms.TextBox();
this.Controls.Add(txtRelationDesc);
txtRelationDesc.Name = "txtRelationDesc";
txtRelationDesc.Top = cLeft * 25;
txtRelationDesc.Left = 200;
txtRelationDesc.Text = "";// "TextBox" + this.cLeft.ToString();
cLeft = cLeft + 1;
flowLayoutPanel1.Controls.Add(txtRelationDesc); } /// <summary>
/// 添加控件事件
/// 涂聚文20150339
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
AddNewTextBox();
}
/// <summary>
/// 获取添的控件的值
/// 涂聚文20150339
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
int s = 0;
int k = 0;
int n = 0; for (int i = 0; i < flowLayoutPanel1.Controls.Count; i++)
{ if (flowLayoutPanel1.Controls[i].GetType() == typeof(ComboBox)) //按类型查找
{ customerRelationTypeID = ((ComboBox)this.flowLayoutPanel1.Controls[i]).SelectedValue.ToString();
}
if (flowLayoutPanel1.Controls[i].GetType() == typeof(TextBox))
{
//MessageBox.Show(((TextBox)this.flowLayoutPanel1.Controls[i]).Name); if (((TextBox)this.flowLayoutPanel1.Controls[i]).Name.Contains("txtName"))
{
customerRelationName = ((TextBox)this.flowLayoutPanel1.Controls[i]).Text.Trim();
}
if (((TextBox)this.flowLayoutPanel1.Controls[i]).Name.Contains("txtTel"))
{
customerRelationTel = ((TextBox)this.flowLayoutPanel1.Controls[i]).Text.Trim();
}
if (((TextBox)this.flowLayoutPanel1.Controls[i]).Name.Contains("txtRelationDesc"))
{
customerRelationDesc = ((TextBox)this.flowLayoutPanel1.Controls[i]).Text.Trim();
}
} if (flowLayoutPanel1.Controls[i].GetType() == typeof(DateTimePicker)) //按类型查找
{ customerBirthday = ((DateTimePicker)this.flowLayoutPanel1.Controls[i]).Value;
} if (IsOdd5(i))
{ customerRelationContactsId = CustomerRelationContactsId; if (Operator == 1)
{ customerRelationshipListInfo.CustomerBirthday = customerBirthday;
customerRelationshipListInfo.CustomerRelationContactsId = customerRelationContactsId;
customerRelationshipListInfo.CustomerRelationDesc = customerRelationDesc;
customerRelationshipListInfo.CustomerRelationName = customerRelationName;
customerRelationshipListInfo.CustomerRelationTel = customerRelationTel;
customerRelationshipListInfo.CustomerRelationTypeID = customerRelationTypeID;
k = customerRelationshipListBLL.InsertCustomerRelationshipList(customerRelationshipListInfo); //MessageBox.Show(customerRelationTypeID + customerRelationName + customerRelationTel);
n++; } } }
if (n > 0)
{
DialogResult dresult = MessageBox.Show("添加了" + n.ToString() + "条联系人", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (dresult == DialogResult.OK)
{
this.Close();
this.DialogResult = DialogResult.OK;
}
}
else
{
DialogResult dresult = MessageBox.Show("存在问题,添加了" + n.ToString() + "条联系人", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (dresult == DialogResult.No)
{
this.Close();
this.DialogResult = DialogResult.OK;
}
if (dresult == DialogResult.Yes)
{
return;
}
} } /// <summary>
/// 判断奇偶数的函數
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static bool IsOdd2(int n)
{
return Convert.ToBoolean(n % 2);
}
/// <summary>
///
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static bool IsOdd5(int n)
{
int b = 0;
bool isb = false;
b = n % 9;
if (n > 0)
{
if (b == 0)
{
isb = true;
}
}
return isb;
}

  

最新文章

  1. 各种JS模板引擎对比数据(高性能JavaScript模板引擎)
  2. fMRI数据分析处理原理及方法
  3. ACE - Reactor实现I/O,Dispatch,Service三层完整服务器(完结)
  4. 兼容iOS 10 资料整理
  5. 一个android应用开发的感悟
  6. 中南民航如何利用K2BPM构建业务流程?
  7. DELPHI 里面的迭代
  8. 征服 Nginx + Tomcat
  9. 足球3v3心得
  10. css新增属性
  11. SpringMVC中使用Swagger2整合
  12. HTML中使用JavaScript的三种方式及优缺点
  13. div,margin,padding
  14. python is not None
  15. Win10蓝屏的一些解决办法
  16. ESP8266 RTOS SDK编译环境搭建
  17. RabbitMQ(2) 一般介绍
  18. tfidf_CountVectorizer 与 TfidfTransformer 保存和测试
  19. pycharm格式化代码 常用快捷键
  20. LOG4J 的配置

热门文章

  1. JSP入门之自定义标签
  2. leetcode-849-到最近的人的最大距离
  3. leetcode-383-Ransom Note(以空间换时间)
  4. 架构师养成记--23.sigar使用实例
  5. SparkSQL中的自定义函数UDF
  6. 腾讯云服务器安装宝塔面板快速配置LNMP/LAMP网站系统
  7. C++默认实参
  8. ospf基础理论
  9. Visual Studio 跨平台開發實戰(1) - Hello Xamarin! (转帖)
  10. 虹软人脸识别在 linux中so文件加载不到的问题