12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using LeaRun.Application.Entity.WarehouseManage;
- using LeaRun.Application.IService.WarehouseManage;
- using LeaRun.Data;
- using LeaRun.Util;
- using LeaRun.Util.WebControl;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LeaRun.Application.Service.WarehouseManage
- {
- public class WarehouseService : IWarehouseManageService
- {
- SqlHelper sqlHelper = new SqlHelper("InstallDB");
- public String getWarehouseList(Pagination pagination)
- {
- String sql = "SELECT WarehouseId,Code,WarehouseName,CreateDt FROM WM_Warehouse";
- DataTable dt;
- StringBuilder sb = new StringBuilder();
- String json = "";
- Char c = ',';
- int total = pagination.records;
- dt = sqlHelper.ExecuteDataTable(sql, "", false, pagination.rows, pagination.page, out total, null);
- pagination.records = total;
- if (dt.Rows.Count > 0)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataRow r = dt.Rows[i];
- #region 拼接sql
- sb.Append("{");
- sb.Append("\"WarehouseId\":\"").Append(r["WarehouseId"].ToString()).Append("\",");
- sb.Append("\"Code\":\"").Append(r["Code"].ToString()).Append("\",");
- sb.Append("\"WarehouseName\":\"").Append(r["WarehouseName"] != System.DBNull.Value ? r["WarehouseName"].ToString() : "").Append("\",");
- sb.Append("\"CreateDt\":\"").Append(r["CreateDt"] != System.DBNull.Value ? Convert.ToDateTime(r["CreateDt"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\"");
- sb.Append("},");
- #endregion
- json = "[" + sb.ToString().TrimEnd(c) + "]";
- }
- }
- return json;
- }
- public void SaveFrom(String Code, String WarehouseName)
- {
- String sql = "Insert into WM_Warehouse(Code,WarehouseName,CreateDt,UpdateDt) Values ('" + Code.Trim() + "','" + WarehouseName + "',GETDATE(),GETDATE())";
- try
- {
- sqlHelper.ExecuteNoParams(sql, CommandType.Text);
- //sql = "update INS_Budget SET PaymentName = '" + op + "' ,PaymentTime = GETDATE() where Apply_ID =" + applyId;
- //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
- }
- catch (Exception ex)
- {
- throw;
- }
- }
- #region 获取仓库列表
- public IEnumerable<WarehouseEntity> getHouseList() {
- try
- {
- string sql = "select WarehouseId,WarehouseName from WM_Warehouse";
- DataTable dt = sqlHelper.ExecuteDataTable(sql, CommandType.Text, null);
- return DataHelper.DataTableToT<WarehouseEntity>(dt);
- }
- catch (Exception)
- {
-
- throw;
- }
-
- }
- #endregion
- }
- }
|