/// <summary>
 /// 增加明细数据表
 /// 关联字段一定是要一一对应,否则系统无法建立其关系
 /// </summary>
 /// <param name="tablename">明细表名称</param>
 /// <param name="detailfield">主从表关联字段-从表字段</param>
 /// <param name="masterfield">主从表关联字段-主表字段</param>
 /// <param name="sortfield">明细表排序字段,可以多个,e.g:ID DESC,OrderNo</param>
 public void AddDetailData(string tablename, string detailfield, string masterfield, string sortfield)
 {
     LDetailTableName.Add(tablename);
     LDetailField.Add(detailfield);
     LMasterField.Add(masterfield);
     DataTable dtTmp = Base.GetDynamicTableData(FormID, tablename);
     LDynamicDetailTableData.Add(dtTmp);
     DynamicDALSetting DALobj = new DynamicDALSetting(dtTmp);
     LDetailDynamicDAL.Add(DALobj);
     string swhere = sortfield != "" ? detailfield + "=" + GetMasterLinkValue(masterfield) + " ORDER BY " + sortfield : detailfield + "=" + GetMasterLinkValue(masterfield);
     LDetailBindingSource.Add(new BindingSource(GetDataSet(DALobj, swhere), "ds"));
 }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="id">单据ID</param>
        /// <param name="trans">SQL事务</param>
        /// <returns></returns>
        public void Delete(DynamicDALSetting DALobj, int id, SqlTransaction trans)
        {
            try
            {
                DALobj.Delete(id, trans);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        /// <summary>
        /// 增加数据
        /// </summary>
        /// <param name="dr">数据行对象</param>
        /// <param name="trans">SQL事务</param>
        /// <returns></returns>
        public int Add(DynamicDALSetting DALobj, DataRow dr, SqlTransaction trans)
        {
            try
            {
                return DALobj.Add(dr, trans);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="dr">数据行对象</param>
 /// <param name="trans">SQL事务</param>
 /// <returns></returns>
 public void Update(DynamicDALSetting DALobj, DataRow dr, SqlTransaction trans)
 {
     try
     {
         DALobj.Update(dr, trans);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// 获取数据集
 /// </summary>
 /// <param name="top">前数据行</param>
 /// <param name="pwhere">条件</param>
 /// <param name="order">排序字段</param>
 /// <returns></returns>
 public DataSet GetDataSet(DynamicDALSetting DALobj, int top, string pwhere, string order)
 {
     try
     {
         return DALobj.GetList(top, pwhere, order);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// 获取数据集
 /// </summary>
 /// <param name="pwhere">条件</param>
 /// <returns></returns>
 public DataSet GetDataSet(DynamicDALSetting DALobj, string pwhere)
 {
     try
     {
         return DALobj.GetList(pwhere); ;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }