Exemplo n.º 1
0
 /// <summary>
 /// 填充模板中的控件内容
 /// </summary>
 private void FillCustomControl()
 {
     try
     {
         //判断用户是单套打印还是多套
         if (EditTemplateInfo.IsMuch)
         {
             //多套打印
             List <EditTemplateDataSource> Muchlist = (List <EditTemplateDataSource>)EditTemplateInfo.EditDataSource;
             //暂时用不到
         }
         else
         {
             //单套打印
             EditTemplateDataSource Oddlist = (EditTemplateDataSource)EditTemplateInfo.EditDataSource;
             DataSet editds = Oddlist.EditGlobalDataSource;//模板数据源
             for (int i = 0; i < editds.Tables.Count; i++)
             {
                 //查找数据源中是否有本模板的DataTable
                 if (editds.Tables[i].TableName == EditEname)
                 {
                     //填充数据
                     foreach (Control child in P_bgimg.Controls)
                     {
                         if (child is DateTimePicker)
                         {
                             //转换时间|特殊类型
                             (child as DateTimePicker).Value = DateTime.Parse(editds.Tables[i].Rows[0][child.Name].ToString());
                         }
                         else if (child is CheckBox)
                         {
                             //状态装换|特殊类型
                             (child as CheckBox).Checked = editds.Tables[i].Rows[0][child.Name].ToString() == "true" ? true : false;
                         }
                         else
                         {
                             child.Text = editds.Tables[i].Rows[0][child.Name].ToString();
                         }
                     }
                 }
             }
         }
     }
     catch (Exception err)
     {
         //MessageBox.Show("填充模板内容错误,数据源缺少字段!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 /// <summary>
 /// 重载构造函数|
 /// </summary>
 /// <param name="editds">模板数据源</param>
 public EditTemplateDSCollection(EditTemplateDataSource editds)
 {
     _EditDSColl.Add(editds);
 }