using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Estsh.Web.Service;
using System.Collections;
using Estsh.Web.Util;
using Estsh.Web.Models;
//2014-07-07 Ada.Li 零件号分级管理
namespace Estsh.Core.Web.Controllers
{
public class LevelPartMasterDefineController : Controller
{
private LevelPartMasterDefineService service = new LevelPartMasterDefineService();
//
// GET: /LevelPartMasterDefine/
public ActionResult Index()
{
return View();
}
///
/// 获取列表数据
///
/// 菜单名称
/// 分页
/// 排序方式
/// 排序列
///
public ActionResult getLevelPartListByPage(string partType , Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getLevelPartListByPage(partType ,pager, direction, sort);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
result.Add("sort", sort);
result.Add("direction", direction);
return Json(result);
}
///
/// 获取零件位置
///
///
public ActionResult getPartLoction()
{
Hashtable result = new Hashtable();
ArrayList PartMasterList = this.service.getPartLoction();
result.Add("list", PartMasterList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 获取配置信息
///
///
public ActionResult getModelName()
{
Hashtable result = new Hashtable();
ArrayList ModelList = this.service.getModelName();
result.Add("list" , ModelList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询供应商信息
///
///
public ActionResult getVendor()
{
Hashtable result = new Hashtable();
ArrayList VendorList = this.service.getVendor();
result.Add("list" , VendorList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询零件单位信息
///
///
public ActionResult getUom()
{
Hashtable result = new Hashtable();
ArrayList UomList = this.service.getUom();
result.Add("list", UomList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询零件默认库位
///
///
public ActionResult getLocate()
{
Hashtable result = new Hashtable();
ArrayList LocateList = this.service.getLocate();
result.Add("list" , LocateList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询供货方式
///
///
public ActionResult getSupply()
{
Hashtable result = new Hashtable();
ArrayList SupplyList = this.service.getSupplyType();
result.Add("list" , SupplyList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询结算方式
///
///
public ActionResult getSettle()
{
Hashtable result = new Hashtable();
ArrayList SettleList = this.service.getSettleType();
result.Add("list" , SettleList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询供货方式
///
///
public ActionResult getInstock()
{
Hashtable result = new Hashtable();
ArrayList InstockList = this.service.getInstockType();
result.Add("list", InstockList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询客户信息
///
///
public ActionResult getCustomer()
{
Hashtable result = new Hashtable();
ArrayList CustomerList = this.service.getCustomer();
result.Add("list" , CustomerList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询条码生成规则
///
///
public ActionResult getRule()
{
Hashtable result = new Hashtable();
ArrayList RuleList = this.service.getRuleSet();
result.Add("list", RuleList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询工艺流程信息
///
///
public ActionResult getRoute()
{
Hashtable result = new Hashtable();
ArrayList RouteList = this.service.getRoute();
result.Add("list", RouteList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 查询厂区信息
///
///
public ActionResult getFactory()
{
Hashtable result = new Hashtable();
ArrayList FacList = this.service.getFactory();
result.Add("list", FacList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 发泡厂保存物料分类
///
///
public ActionResult getOption10()
{
Hashtable result = new Hashtable();
ArrayList OptionList = this.service.getOption10();
result.Add("list", OptionList);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 保存、更新零件号信息
///
///
public ActionResult saveLevelPartMasterDefine()
{
Hashtable result = new Hashtable();
Hashtable htParams = new Hashtable();
UserInfo user = (UserInfo)Session["loginedUser"];
String editType = Request["editType"].ToString();
//基本属性
string partSpec = Request["part_spec"].ToString();
htParams.Add("@part_spec", partSpec);
string partSpec2 = Request["part_spec2"].ToString();
htParams.Add("@part_spec2", partSpec2);
string partNo = Request["part_no"].ToString();
htParams.Add("@part_no", partNo);
string custPart = Request["cust_part_no"].ToString();
htParams.Add("@cust_part_no", custPart);
string part3C = Request["part_no_3c"].ToString();
htParams.Add("@part_no_3c", part3C);
string vendorID = Request["vendor_id"].ToString();
htParams.Add("@vendor_id", string.IsNullOrEmpty(vendorID) ? 0 : Convert.ToInt32(vendorID));
string partLocation = Request["part_location"].ToString();
htParams.Add("@part_location", partLocation);
string vendorPart = Request["vendor_part_no"].ToString();
htParams.Add("@vendor_part_no", vendorPart);
string modelID = Request["model_id"].ToString();
htParams.Add("@model_id", string.IsNullOrEmpty(modelID)?0:Convert.ToInt32(modelID));
string mfgerPart = Request["mfger_part_no"].ToString();
htParams.Add("@mfger_part_no", mfgerPart);
string uom = Request["uom"].ToString();
htParams.Add("@uom", uom);
string erpPart = Request["erp_part_no"].ToString();
htParams.Add("@erp_part_no", erpPart);
string partClass = Request["part_class"].ToString();
htParams.Add("@part_class", partClass);
string version = Request["version"].ToString();
htParams.Add("@version", version);
//物料属性
string labelFile = Request["label_file"].ToString();
htParams.Add("@label_file", labelFile);
string labelType = Request["label_type"].ToString();
htParams.Add("@label_type", labelType);
string minPackQty = Request["min_pack_qty"].ToString();
htParams.Add("@min_pack_qty", string.IsNullOrEmpty(minPackQty)?0:Convert.ToDecimal(minPackQty));
string batchControl = Request["batch_control"].ToString();
htParams.Add("@batch_control", batchControl);
string locateID = Request["locate_id"].ToString();
htParams.Add("@locate_id", string.IsNullOrEmpty(locateID)?0:Convert.ToInt32(locateID));
string minStockQty = Request["min_stock_qty"].ToString();
htParams.Add("@min_stock_qty", string.IsNullOrEmpty(minStockQty)?0:Convert.ToDecimal(minStockQty));
string splitFlag = Request["split_flag"].ToString();
htParams.Add("@split_flag", splitFlag);
string defaultBoxQty = Request["default_box_qty"].ToString();
htParams.Add("@default_box_qty", string.IsNullOrEmpty(defaultBoxQty)?0:Convert.ToDecimal(defaultBoxQty));
string maxStockQty = Request["max_stock_qty"].ToString();
htParams.Add("@max_stock_qty", string.IsNullOrEmpty(maxStockQty)?0:Convert.ToDecimal(maxStockQty));
string overRequest = Request["over_request"].ToString();
htParams.Add("@over_request", overRequest);
string defaultReelQty = Request["default_reel_qty"].ToString();
htParams.Add("@default_reel_qty", string.IsNullOrEmpty(defaultReelQty)?0:Convert.ToDecimal(defaultReelQty));
string indate = Request["indate"].ToString();
htParams.Add("@indate", indate);
string indateFlag = Request["indate_flag"].ToString();
htParams.Add("@indate_flag", indateFlag);
string defaultSetQty = Request["default_set_qty"].ToString();
htParams.Add("@default_set_qty", string.IsNullOrEmpty(defaultSetQty)?0:Convert.ToDecimal(defaultSetQty));
string wipMinqty = Request["wip_min_stock_qty"].ToString();
htParams.Add("@wip_min_stock_qty", string.IsNullOrEmpty(wipMinqty)?0:Convert.ToDecimal(wipMinqty));
string recheckCycle = Request["recheck_cycle"].ToString();
htParams.Add("@recheck_cycle", recheckCycle);
string settle = Request["settle_type"].ToString();
htParams.Add("@settle_type", settle);
string supply = Request["supply_type"].ToString();
htParams.Add("@supply_type", supply);
string packageSize = Request["package_size"].ToString();
htParams.Add("@package_size", packageSize);
string instock = Request["instock_type"].ToString();
htParams.Add("@instock_type", instock);
//生产属性
string ruleSet = Request["rule_set"].ToString();
htParams.Add("@rule_set", ruleSet);
string customeID = Request["custome_id"].ToString();
htParams.Add("@custome_id", string.IsNullOrEmpty(customeID)?0:Convert.ToInt32(customeID));
string partAbc = Request["part_abc"].ToString();
htParams.Add("@part_abc", partAbc);
string routeID = Request["route_id"].ToString();
htParams.Add("@route_id", string.IsNullOrEmpty(routeID)?0:Convert.ToInt32(routeID));
string factoryCode = Request["factory_code"].ToString();
htParams.Add("@factory_code", factoryCode);
string partGroup = Request["part_group"].ToString();
htParams.Add("@part_group", partGroup);
string samplingPlanID = Request["sampling_plan_id"].ToString();
htParams.Add("@sampling_plan_id", string.IsNullOrEmpty(samplingPlanID)?0:Convert.ToInt32(samplingPlanID));
string option3 = Request["option3"].ToString();
htParams.Add("@option3", option3);
string burnTime = Request["burnin_time"].ToString();
htParams.Add("burnin_time", burnTime);
string bklas = Request["BKLAS"].ToString();
htParams.Add("@BKLAS", bklas);
string subboardQty = Request["subboard_qty"].ToString();
htParams.Add("@subboard_qty", string.IsNullOrEmpty(subboardQty)?0:Convert.ToDecimal(subboardQty));
string mcCode = Request["mc_code"].ToString();
htParams.Add("@mc_code", mcCode);
string upcCode = Request["upc_code"].ToString();
htParams.Add("@upc_code", upcCode);
string labelQty = Request["label_qty"].ToString();
htParams.Add("@label_qty", string.IsNullOrEmpty(labelQty)?0:Convert.ToInt32(labelQty));
string uccCode = Request["ucc_code"].ToString();
htParams.Add("@ucc_code", uccCode);
string option5 = Request["option5"].ToString();
htParams.Add("@option5", option5);
string eanCode = Request["ean_code"].ToString();
htParams.Add("@ean_code", eanCode);
string partType = Request["part_type"].ToString();
htParams.Add("@part_type", string.IsNullOrEmpty(partType)?0:Convert.ToInt32(partType));
//基本属性2
string uom1 = Request["uom1"].ToString();
htParams.Add("@uom1", uom1);
string option7 = Request["option7"].ToString();
htParams.Add("@option7", option7);
string coefficient1 = Request["coefficient1"].ToString();
htParams.Add("@coefficient1", coefficient1);
string option6 = Request["option6"].ToString();
htParams.Add("@option6", option6);
string uom2 = Request["uom2"].ToString();
htParams.Add("@uom2", uom2);
string option8 = Request["option8"].ToString();
htParams.Add("@option8", option8);
string coefficient2 = Request["coefficient2"].ToString();
htParams.Add("@coefficient2", coefficient2);
string option9 = Request["option9"].ToString();
htParams.Add("@option9", option9);
string uom3 = Request["uom3"].ToString();
htParams.Add("@uom3", uom3);
string option10 = Request["option10"].ToString();
htParams.Add("@option10", option10);
string coefficient3 = Request["coefficient3"].ToString();
htParams.Add("@coefficient3", coefficient3);
string option11 = Request["option11"].ToString();
htParams.Add("@option11", option11);
string option1 = Request["option1"].ToString();
htParams.Add("@option1", option1);
string option12 = Request["option12"].ToString();
htParams.Add("@option12", option12);
string option2 = Request["option2"].ToString();
htParams.Add("@option2", option2);
string option13 = Request["option13"].ToString();
htParams.Add("@option13", option13);
String message = string.Empty;
string flag = "";
if (!string.IsNullOrEmpty(editType) && editType.Equals("edit"))
{
try
{
String partID = Request["part_id"].ToString();
htParams.Add("@part_id", partID);
htParams.Add("@update_userid", user.updateUserId);
int num = this.service.updateLevelPartMasterDefine(htParams);
if (num > 0)
{
message = "修改成功";
flag = "OK";
}
else
{
message = "修改失败";
flag = "Fail";
}
}
catch (Exception ee)
{
flag = "Fail";
message = "修改失败," + ee.Message;
}
}
else
{
try
{
htParams.Add("@create_userid", user.createUserId);
int num = this.service.saveLevelPartMasterDefine(htParams);
if (num > 0)
{
message = "添加成功";
flag = "OK";
}
else
{
flag = "Fail";
message = "添加失败";
}
}
catch (Exception ee)
{
message = "添加失败," + ee.Message;
flag = "Fail";
}
}
result.Add("message", message);
result.Add("flag", flag);
return Json(result);
}
///
/// 删除数据
///
///
///
public ActionResult deleteLevelPartMasterDefine(string part_id)
{
int count = 0;
try
{
count = this.service.deleteLevelPartMasterDefine(part_id);
}
catch
{
count = -1;
}
Hashtable result = new Hashtable();
result.Add("status", count);
return Json(result);
}
///
/// 编辑
///
///
///
public ActionResult editLevelPartMasterDefine(string part_id)
{
ArrayList PartMasterInfo = this.service.GetLevelPartList(part_id);
Hashtable htPartMasterInfo = (Hashtable)PartMasterInfo[0];
ViewData.Add("editType", "edit");
ViewData.Add("part_id", part_id);
ViewData.Add("part_spec", htPartMasterInfo["part_spec"]);
ViewData.Add("part_spec2", htPartMasterInfo["part_spec2"]);
ViewData.Add("part_no", htPartMasterInfo["part_no"]);
ViewData.Add("part_type", htPartMasterInfo["part_type"]);
ViewData.Add("part_location", htPartMasterInfo["part_location"]);
ViewData.Add("model_id", htPartMasterInfo["model_id"]);
ViewData.Add("version", htPartMasterInfo["version"]);
ViewData.Add("cust_part_no", htPartMasterInfo["cust_part_no"]);
ViewData.Add("mfger_part_no", htPartMasterInfo["mfger_part_no"]);
ViewData.Add("vendor_part_no", htPartMasterInfo["vendor_part_no"]);
ViewData.Add("erp_part_no", htPartMasterInfo["erp_part_no"]);
ViewData.Add("uom", htPartMasterInfo["uom"]);
ViewData.Add("label_file", htPartMasterInfo["label_file"]);
ViewData.Add("label_type", htPartMasterInfo["label_type"]);
ViewData.Add("locate_id", htPartMasterInfo["locate_id"]);
ViewData.Add("default_box_qty", htPartMasterInfo["default_box_qty"]);
ViewData.Add("default_reel_qty", htPartMasterInfo["default_reel_qty"]);
ViewData.Add("default_set_qty", htPartMasterInfo["default_set_qty"]);
ViewData.Add("min_pack_qty", htPartMasterInfo["min_pack_qty"]);
ViewData.Add("min_stock_qty", htPartMasterInfo["min_stock_qty"]);
ViewData.Add("max_stock_qty", htPartMasterInfo["max_stock_qty"]);
ViewData.Add("indate", htPartMasterInfo["indate"]);
ViewData.Add("batch_control", htPartMasterInfo["batch_control"]);
ViewData.Add("split_flag", htPartMasterInfo["split_flag"]);
ViewData.Add("over_request", htPartMasterInfo["over_request"]);
ViewData.Add("indate_flag", htPartMasterInfo["indate_flag"]);
ViewData.Add("rule_set", htPartMasterInfo["rule_set"]);
ViewData.Add("route_id", htPartMasterInfo["route_id"]);
ViewData.Add("burnin_time", htPartMasterInfo["burnin_time"]);
ViewData.Add("subboard_qty", htPartMasterInfo["subboard_qty"]);
ViewData.Add("upc_code", htPartMasterInfo["upc_code"]);
ViewData.Add("ucc_code", htPartMasterInfo["ucc_code"]);
ViewData.Add("ean_code", htPartMasterInfo["ean_code"]);
ViewData.Add("uom1", htPartMasterInfo["uom1"]);
ViewData.Add("uom2", htPartMasterInfo["uom2"]);
ViewData.Add("uom3", htPartMasterInfo["uom3"]);
ViewData.Add("coefficient1", htPartMasterInfo["coefficient1"]);
ViewData.Add("coefficient2", htPartMasterInfo["coefficient2"]);
ViewData.Add("coefficient3", htPartMasterInfo["coefficient3"]);
ViewData.Add("option6", htPartMasterInfo["option6"]);
ViewData.Add("option8", htPartMasterInfo["option8"]);
ViewData.Add("option9", htPartMasterInfo["option9"]);
ViewData.Add("option10", htPartMasterInfo["option10"]);
ViewData.Add("option11", htPartMasterInfo["option11"]);
ViewData.Add("option12", htPartMasterInfo["option12"]);
ViewData.Add("option2", htPartMasterInfo["option2"]);
ViewData.Add("option13", htPartMasterInfo["option13"]);
ViewData.Add("option7", htPartMasterInfo["option7"]);
ViewData.Add("option5", htPartMasterInfo["option5"]);
ViewData.Add("mc_code", htPartMasterInfo["mc_code"]);
ViewData.Add("BKLAS", htPartMasterInfo["BKLAS"]);
ViewData.Add("option3", htPartMasterInfo["option3"]);
ViewData.Add("sampling_plan_id", htPartMasterInfo["sampling_plan_id"]);
ViewData.Add("part_group", htPartMasterInfo["part_group"]);
ViewData.Add("factory_code", htPartMasterInfo["factory_code"]);
ViewData.Add("part_abc", htPartMasterInfo["part_abc"]);
ViewData.Add("custome_id", htPartMasterInfo["custome_id"]);
ViewData.Add("part_class", htPartMasterInfo["part_class"]);
return View("~/Views/LevelPartMasterDefine/EditLevelPartMasterDefine.aspx");
}
}
}