C#中持久层事物数组方式的调用模板

C#访问数据库事物简单模板

  /// 계획오더(LTP)[UPLOAD]내역 저장
        /// 
        /// 파라미터
        /// 
        public DataSet GET_DYERP_MM1U36_2(DataTable dt)
        {
            string[] strReurn = null;
            DataSet dsReurn = new DataSet();

            try
            {
                using (System.Transactions.TransactionScope transcope = new System.Transactions.TransactionScope())
                {
                    ArrayList aerrQuery = new ArrayList();

                    if (dt.Rows.Count > 0)
                    {
                        for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
                        {
                            DataTable dtParam = dt.Clone();

                            dtParam.Rows.Clear();
                            dtParam.Rows.Add();
                            dtParam.Rows[0]["BUKRS"] = dt.Rows[iRow]["BUKRS"];
                            dtParam.Rows[0]["WERKS"] = dt.Rows[iRow]["WERKS"];
                            dtParam.Rows[0]["CSTNO"] = dt.Rows[iRow]["CSTNO"];
                            dtParam.Rows[0]["CSTNONM"] = dt.Rows[iRow]["CSTNONM"];
                            dtParam.Rows[0]["MATNR"] = dt.Rows[iRow]["MATNR"];
                            dtParam.Rows[0]["MATCOD"] = dt.Rows[iRow]["MATCOD"];
                            dtParam.Rows[0]["MATCODNM"] = dt.Rows[iRow]["MATCODNM"];
                            dtParam.Rows[0]["ODNUM"] = dt.Rows[iRow]["ODNUM"];
                            dtParam.Rows[0]["NDATE"] = dt.Rows[iRow]["NDATE"];
                            dtParam.Rows[0]["NNUM"] = dt.Rows[iRow]["NNUM"];
                            dtParam.Rows[0]["LOTNO"] = dt.Rows[iRow]["LOTNO"];
                            dtParam.Rows[0]["BNUM"] = dt.Rows[iRow]["BNUM"];
                            dtParam.Rows[0]["BCOD"] = dt.Rows[iRow]["BCOD"];


                            aerrQuery.Clear();

                            foreach (string sInsert in (ArrayList)helper.getQuery("USP_DYERP_MM1U36_2", dtParam))
                            {
                                aerrQuery.Add(sInsert);

                                strReurn = helper.ExecuteStringTransactionReturnCreateIDArray(aerrQuery);

                                if (strReurn[0] != "S")
                                {
                                    break;
                                }
                            }//end for

                            if (strReurn[0] != "S") break;

                        }//end for

                        if (strReurn[0] == "S")
                        {
                            transcope.Complete();
                        }
                    }//end if
                }//end using()

                dsReurn = strReurn[0] == "S" ? DY_COMMON.set_returnDataset("S", "저장이 성공했습니다.") : DY_COMMON.set_returnDataset("E", "저장이 실패 되었습니다.");

                return dsReurn;

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }
···

你可能感兴趣的:(C#中持久层事物数组方式的调用模板)