Esempio n. 1
0
        /// <summary>
        /// 选择导入数据
        /// </summary>
        /// <param name="dsDetail">导入目标数据源</param>
        /// <param name="reportno">查询编号</param>
        /// <param name="fields">导入的字段,e.g: a=b,c=d 其中a和c为目标数据源中的字段,b和d为选择数据源中的字段,多个用英文逗号“,”进行分割</param>
        /// <param name="where">选择数据源的过滤条件</param>
        /// <param name="isautoselect">是否默认选中所有数据</param>
        public void SelectData(BindingSource dsDetail, string reportno, string fields, string where,bool isautoselect)
        {
            //数据选择窗体
            frmCommSelectForm frm = new frmCommSelectForm(reportno, where, isautoselect);
            frm.StartPosition = FormStartPosition.CenterParent;
            frm.WindowState = FormWindowState.Normal;
            frm.ReportNo = reportno;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                //解析需要设置值的字段
                string[] fieldstring = Public.GetSplitString(fields, ",");
                List<string> ValueFields = new List<string>();
                List<string> DataFields = new List<string>();
                foreach (string s in fieldstring)
                {
                    string[] ss = Public.GetSplitString(s, "=");
                    DataFields.Add(ss[0]);
                    ValueFields.Add(ss[1]);
                }

                //插入数据
                foreach (DataRow dr in frm.ResultData)
                {
                    dsDetail.AddNew();
                    for (int i = 0; i < DataFields.Count; i++)
                    {
                        ((DataRowView)dsDetail.Current).Row[DataFields[i]] = dr[ValueFields[i]];
                    }
                    dsDetail.EndEdit();
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 选择导入数据
 /// </summary>
 /// <param name="reportno">查询编号</param>
 /// <param name="where">选择数据源的过滤条件</param>
 /// <param name="isautoselect">是否默认选中所有数据</param>
 /// <returns>选择的数据集</returns>
 public List<DataRow> SelectData(string reportno, string where, bool isautoselect)
 {
     //数据选择窗体
     frmCommSelectForm frm = new frmCommSelectForm(reportno, where, isautoselect);
     frm.ReportNo = reportno;
     frm.StartPosition = FormStartPosition.CenterParent;
     frm.WindowState = FormWindowState.Normal;
     if (frm.ShowDialog() == DialogResult.OK)
         return frm.ResultData.ToList();
     else
         return null;
 }