Beispiel #1
0
        void IBLL.ICusFY.Add(Model.rp_t_supcust_fy_master ord, List <Model.rp_t_supcust_fy_detail> lines, out string sheet_no)
        {
            var db = new DB.DBByHandClose(Appsetting.conn);

            DB.IDB d = db;
            try
            {
                db.Open();
                db.BeginTran();
                //
                IBLL.ICusFY bll = this;
                sheet_no = ord.sheet_no = bll.MaxCode();
                string sql = "select * from rp_t_supcust_fy_master where sheet_no='" + ord.sheet_no + "'";
                //
                var tb = d.ExecuteToTable(sql, null);
                if (tb.Rows.Count != 0)
                {
                    throw new Exception("已存在单号" + ord.sheet_no);
                }
                d.Insert(ord);
                foreach (Model.rp_t_supcust_fy_detail line in lines)
                {
                    sql           = "select isnull(max(flow_id)+1,1) from rp_t_supcust_fy_detail";
                    line.flow_id  = Helper.Conv.ToInt64(d.ExecuteScalar(sql, null));
                    line.sheet_no = sheet_no;
                    d.Insert(line);
                }
                //
                db.CommitTran();
            }
            catch (Exception ex)
            {
                db.RollBackTran();
                throw;
            }
            finally
            {
                db.Close();
            }
        }