// POST: /Assay_BillMain/Create
/// <summary>
/// 批量新增数据
/// </summary>
/// <param name="assay_billmain"></param>
/// <param name="fc"></param>
/// <param name="assau_billdetail"></param>
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Assay_BillMain assay_billmain,FormCollection fc,Assay_BillDetail assau_billdetail)
{
int BillMain_PTR = 0;
string[] ItemNoArr = new string[] { };
string[] TankNoArr = new string[] { };
string[] ItemArr = new string[] { };
string[] MeiRangeArr = new string[] { };
string[] AnalyseRangeArr = new string[] { };
string[] ResultArr = new string[] { };
string[] MethodsArr = new string[] { };
string[] ChemicalsArr = new string[] { };
string[] QuantityArr = new string[] { };
string[] FinalResultArr = new string[] { };
string[] FinalTimeArr = new string[] { };
if (ModelState.IsValid)
{
db.Assay_BillMain.Add(assay_billmain);
db.SaveChanges();
string strMaxSql = "select * from dbo.Assay_BillMain where RKEY=(select max(RKEY) from dbo.Assay_BillMain);";
DataSet ds = SqlHelper.Query(strMaxSql);
if (ds.Tables[0].Rows.Count > 0)
{
BillMain_PTR = Convert.ToInt32(ds.Tables[0].Rows[0]["RKEY"]);
}
ItemNoArr = fc["ItemNo"].Split(',');
TankNoArr = fc["TankNo"].Split(',');
ItemArr = fc["Item"].Split(',');
MeiRangeArr = fc["MeiRange"].Split(',');
AnalyseRangeArr = fc["AnalyseRange"].Split(',');
ResultArr = fc["Result"].Split(',');
MethodsArr = fc["Methods"].Split(',');
ChemicalsArr = fc["Chemicals"].Split(',');
QuantityArr = fc["Quantity"].Split(',');
FinalResultArr = fc["FinalResult"].Split(',');
FinalTimeArr = fc["FinalTime"].Split(',');
for (int n = 0; n < ItemNoArr.Length; n++)
{
assau_billdetail = new Assay_BillDetail();
assau_billdetail.BillMain_PTR = BillMain_PTR;
assau_billdetail.ItemNo =Convert.ToInt16(ItemNoArr[n]);
assau_billdetail.TankNo = TankNoArr[n];
assau_billdetail.Item = ItemArr[n];
assau_billdetail.MeiRange = MeiRangeArr[n];
assau_billdetail.AnalyseRange = AnalyseRangeArr[n];
assau_billdetail.Result = ResultArr[n];
assau_billdetail.Methods = MethodsArr[n];
assau_billdetail.Chemicals = ChemicalsArr[n];
assau_billdetail.Quantity = QuantityArr[n];
assau_billdetail.FinalResult = FinalResultArr[n];
assau_billdetail.FinalTime = FinalTimeArr[n];
db.Assay_BillDetail.Add(assau_billdetail);
db.SaveChanges();
}
return Content("<script type='text/javascript'>alert('单据录入成功!');window.location.href='/Assay_BillMain/Create'</script>");
}
ViewBag.Process_PTR = new SelectList(db.Assay_Process, "RKEY", "ProcessName", assay_billmain.Process_PTR);
ViewBag.Type_PTR = new SelectList(db.EnmItemValues, "RKEY", "ItemValue", assay_billmain.Type_PTR);
return View(assay_billmain);
}