You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/OA/Controllers/GoodsValueController.cs

165 lines
6.5 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using DSWeb.Areas.OA.Models.GoodsValue;
using DSWeb.Areas.CommMng.Models;
using DSWeb.TruckMng.Helper;
using DSWeb.TruckMng.Helper.Repository;
using Microsoft.Practices.EnterpriseLibrary.Data;
using HcUtility.Comm;
using HcUtility.Core;
8 months ago
using DSWeb.SoftMng.Filter;
2 years ago
namespace DSWeb.Areas.OA.Controllers
{
/// <summary>
/// 项目信息明细
/// </summary>
public class GoodsValueController : Controller
{
//
// GET: /Import/RptImportFeedetail/
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
8 months ago
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
2 years ago
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = GetDataList(condition,sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
8 months ago
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
2 years ago
private static List<GoodsValuemb> GetDataList(string strCondition,string sort)
{
var strSql = new StringBuilder();
strSql.Append(" select GID NID,WMSDATE,CUSTOMERNAME,BLNO,CUSTNO,INPUTBY,USERID,COMPANYID,DEPTID, ");
strSql.Append(" STORAGENAME,GOODSNAME,GOODSSTOCK,BANKVALUE,OPTIME_1,MARKETVALUE,OPTIME_2,BANKPRICE,MARKETPRICE ");
strSql.Append(" from v_oa_goodsvalue ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
return SetData(strSql);
}
private static List<GoodsValuemb> SetData(StringBuilder strSql)
{
var headList = new List<GoodsValuemb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new GoodsValuemb();
#region Set DB data to Object
data.NID = Convert.ToString(reader["NID"]);
data.WMSDATE = Convert.ToString(reader["WMSDATE"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.BLNO = Convert.ToString(reader["BLNO"]);
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
data.USERID = Convert.ToString(reader["USERID"]);
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
data.DEPTID = Convert.ToString(reader["DEPTID"]);
data.STORAGENAME = Convert.ToString(reader["STORAGENAME"]);
data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);
data.GOODSSTOCK = Convert.ToString(reader["GOODSSTOCK"]);
data.BANKVALUE = Convert.ToString(reader["BANKVALUE"]);
data.OPTIME_1 = Convert.ToString(reader["OPTIME_1"]);
data.MARKETVALUE = Convert.ToString(reader["MARKETVALUE"]);
data.OPTIME_2 = Convert.ToString(reader["OPTIME_2"]);
data.BANKPRICE = Convert.ToString(reader["BANKPRICE"]);
data.MARKETPRICE = Convert.ToString(reader["MARKETPRICE"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#region 修改marketvalue和bankvalue
static public int ChangeValue(string marketvalue,string bankvalue,string OP,List<string> NID)
{
/*
var strSql = new StringBuilder();
strSql.Append(" delete from [Import_KC] where cargo_id in( " + cargo_id + ")");
strSql.Append(" insert into [Import_KC] ");
strSql.Append(" select [ContractNo],id [cargo_id],0 [CZState] ,");
strSql.Append(" boxcount as [InNum],0 [OutNum],0 kcstate,(getdate()) kcdate,");
strSql.Append(" '' [text],null,null,null,null,null,null,null ");
strSql.Append(" from import_cargo where id in( " + cargo_id + ")");
return setKCStart(strSql);//ExecuteNonQuery
* */
return 0;
}
public ContentResult ChangeGoodsValue(string ChangeDate, string MarketValue, string BankValue, string BSNOSql)
{
var count_1 = 0;
//var count_2 = 0;
Database db = DatabaseFactory.CreateDatabase();
var Str1 = new StringBuilder();
Str1.Append( " update wms set ");
if (MarketValue != "")
{
Str1.Append(" MarketValue = " + MarketValue + " ");
if (BankValue != "")
{
Str1.Append(" ,BankValue = " + BankValue + " ");
}
}
else if (BankValue != "")
{
Str1.Append(" BankValue = " + BankValue + " ");
}
if (Str1.ToString() != " update wms set ") {
Str1.Append(" where gid in " + BSNOSql + "");
count_1 = db.ExecuteNonQuery(CommandType.Text, Str1.ToString());
}
/*
var Str2 = "";
count_2 = db.ExecuteNonQuery(CommandType.Text, Str2.ToString());
*/
var _t= "0";
if (count_1 > 0)
{
var json = JsonConvert.Serialize(new { Success = true, Message = "修改成功", totalCount = count_1, _t });
return new ContentResult() { Content = json };
}
else {
var json = JsonConvert.Serialize(new { Success = false, Message = "修改失败", totalCount = count_1, _t });
return new ContentResult() { Content = json };
}
}
#endregion
}
}