| | |
| | | |
| | | return Traceability; |
| | | } |
| | | |
| | | public dynamic ProductBinding(dynamic query) |
| | | { |
| | | if (query == null) throw new ArgumentNullException(nameof(query), "参数对象不能为 null"); |
| | | |
| | | // 2. 使用 string.IsNullOrEmpty 直接判断字符串属性(避免 NullReferenceException) |
| | | if (string.IsNullOrEmpty(query.userName?.ToString())) |
| | | throw new ArgumentException("用户名不允许为空", nameof(query.userName)); |
| | | |
| | | if (string.IsNullOrEmpty(query.ZsBar?.ToString())) |
| | | throw new ArgumentException("追溯码不允许为空", nameof(query.ZsBar)); |
| | | |
| | | if (string.IsNullOrEmpty(query.LsBar?.ToString())) |
| | | throw new ArgumentException("后盖码不允许为空", nameof(query.LsBar)); |
| | | |
| | | var _strMsg = ""; |
| | | var _intSum = ""; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("prc_pda_product_binding", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName }, |
| | | new("@pi_trac_barcode", SqlDbType.NVarChar, 100) { Value = query.ZsBar }, |
| | | new("@pi_ls_barcode", SqlDbType.NVarChar, 100) { Value = query.LsBar }, |
| | | new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output }, |
| | | new("@po_outStatus", SqlDbType.Int) { Direction = ParameterDirection.Output } |
| | | }; |
| | | |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | |
| | | cmd.ExecuteNonQuery(); |
| | | |
| | | _strMsg = parameters[3].Value?.ToString() ?? ""; |
| | | _intSum = parameters[4].Value?.ToString() ?? "-1"; |
| | | |
| | | var result = Convert.ToInt32(_intSum); |
| | | if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | | var dto = new |
| | | { |
| | | message = _strMsg, |
| | | status = result, |
| | | tracBarcode = query.ZsBar |
| | | }; |
| | | |
| | | return dto; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |