//上传西服上衣尺码表 public bool Import_XF_SY(DataTable table, string size_code, string gender, out string errmsg) { try { List <XF_SY_NAN_ChiMaDto> list = new List <XF_SY_NAN_ChiMaDto>(); for (int i = 0; i < table.Rows.Count; i++) { #region 处理不符合要求得数据 DataRow row = table.Rows[i]; row.BeginEdit(); for (int a = 0; a < table.Columns.Count; a++) { if (row[a].ToString().IndexOf("....") > 0) { row[a] = row[a].ToString().Replace("....", "."); } if (row[a].ToString().IndexOf("...") > 0) { row[a] = row[a].ToString().Replace("...", "."); } if (row[a].ToString().IndexOf("..") > 0) { row[a] = row[a].ToString().Replace("..", "."); } } row.EndEdit(); #endregion } if (gender == "男") { for (int i = 0; i < table.Rows.Count; i++) { XF_SY_NAN_ChiMaDto cs = new XF_SY_NAN_ChiMaDto(); cs.Height = Convert.ToDecimal(table.Rows[i]["Height"]); cs.FrontLength = table.Rows[i]["FrontLength"] + ""; cs.NetBust = table.Rows[i]["NetBust"] + ""; cs.FinishedBust = Convert.ToDecimal(table.Rows[i]["FinishedBust"]); cs.InWaist = Convert.ToDecimal(table.Rows[i]["InWaist"]); cs.FinishedHem_NoFork = Convert.ToDecimal(table.Rows[i]["FinishedHem_NoFork"]); cs.FinishedHem_SplitEnds = Convert.ToDecimal(table.Rows[i]["FinishedHem_SplitEnds"]); cs.ShoulderWidth = Convert.ToDecimal(table.Rows[i]["ShoulderWidth"]); cs.Size_Code = size_code; cs.Sleecve_Show = table.Rows[i]["FK_Sleeve_ID"] + ""; cs.CreateDateTime = DateTime.Now; cs.IsDeleted = false; cs.Status = 1; list.Add(cs); } XF_SY_NAN_ChiMa.Add(list); } else { List <XF_SY_NU_CodeSizeDto> list_NU = new List <XF_SY_NU_CodeSizeDto>(); for (int i = 0; i < table.Rows.Count; i++) { XF_SY_NU_CodeSizeDto cs = new XF_SY_NU_CodeSizeDto(); cs.Height = Convert.ToDecimal(table.Rows[i]["Height"]); cs.FrontLength = table.Rows[i]["FrontLength"] + ""; cs.NetBust = table.Rows[i]["NetBust"] + ""; cs.FinishedBust = Convert.ToDecimal(table.Rows[i]["FinishedBust"]); cs.InWaist = Convert.ToDecimal(table.Rows[i]["InWaist"]); cs.FinishedHem_NoFork = Convert.ToDecimal(table.Rows[i]["FinishedHem_NoFork"]); cs.SleeveWidth = Convert.ToDecimal(table.Rows[i]["SleeveWidth"]); cs.ShoulderWidth = Convert.ToDecimal(table.Rows[i]["ShoulderWidth"]); cs.Size_Code = size_code; cs.Sleecve_Show = table.Rows[i]["FK_Sleeve_ID"] + ""; cs.CreateDateTime = DateTime.Now; cs.IsDeleted = false; cs.Status = 1; list_NU.Add(cs); } XF_SY_NU_ChiMa.Add(list_NU); } errmsg = ""; return(true); } catch (Exception ex) { errmsg = ex.Message; return(false); } }
public JsonResult UpdateCode(FormCollection fm) { using (var db = new MySqlServer()) try { switch (fm["Action"]) { case "XF_SY_NAN": List <XF_SY_NAN_ChiMaDto> xfnanlist = new List <XF_SY_NAN_ChiMaDto>(); int count = fm["Height"].Split(',').Count(); for (int i = 0; i < count; i++) { int upid = 0; if (!int.TryParse(fm["ID"].Split(',')[i], out upid)) { XF_SY_NAN_ChiMaDto tjdto = new XF_SY_NAN_ChiMaDto(); tjdto.Height = Convert.ToInt32(fm["Height"].Split(',')[i]); tjdto.FrontLength = fm["FrontLength"].Split(',')[i]; tjdto.NetBust = fm["NetBust"].Split(',')[i]; tjdto.FinishedBust = Convert.ToDecimal(fm["FinishedBust"].Split(',')[i]); tjdto.InWaist = Convert.ToDecimal(fm["InWaist"].Split(',')[i]); tjdto.FinishedHem_NoFork = Convert.ToDecimal(fm["FinishedHem_NoFork"].Split(',')[i]); tjdto.FinishedHem_SplitEnds = Convert.ToDecimal(fm["FinishedHem_SplitEnds"].Split(',')[i]); tjdto.ShoulderWidth = Convert.ToDecimal(fm["ShoulderWidth"].Split(',')[i]); tjdto.Sleecve_Show = fm["Sleecve_Show"].Split(',')[i]; tjdto.Id = upid; tjdto.Status = 0; tjdto.Size_Code = fm["Size_Code"]; XF_SY_NAN_ChiMa.Update(tjdto); } else { XF_SY_NAN_ChiMaDto xfnan = XF_SY_NAN_ChiMa.GetOne(t => t.Id == upid); xfnan.Height = Convert.ToInt32(fm["Height"].Split(',')[i]); xfnan.FrontLength = fm["FrontLength"].Split(',')[i]; xfnan.NetBust = fm["NetBust"].Split(',')[i]; xfnan.FinishedBust = Convert.ToDecimal(fm["FinishedBust"].Split(',')[i]); xfnan.InWaist = Convert.ToDecimal(fm["InWaist"].Split(',')[i]); xfnan.FinishedHem_NoFork = Convert.ToDecimal(fm["FinishedHem_NoFork"].Split(',')[i]); xfnan.FinishedHem_SplitEnds = Convert.ToDecimal(fm["FinishedHem_SplitEnds"].Split(',')[i]); xfnan.ShoulderWidth = Convert.ToDecimal(fm["ShoulderWidth"].Split(',')[i]); xfnan.Sleecve_Show = fm["Sleecve_Show"].Split(',')[i]; xfnan.Id = upid; xfnan.Status = 1; XF_SY_NAN_ChiMa.Update(xfnan); } } break; case "XF_SY_NU": int count2 = fm["Height"].Split(',').Count(); List <XF_SY_NU_CodeSizeDto> synulist = new List <XF_SY_NU_CodeSizeDto>(); for (int i = 0; i < count2; i++) { int upid = 0; if (!int.TryParse(fm["ID"].Split(',')[i], out upid)) { XF_SY_NU_CodeSizeDto synu = new XF_SY_NU_CodeSizeDto(); synu.Height = Convert.ToDecimal(fm["Height"].Split(',')[i]); synu.FrontLength = fm["FrontLength"].Split(',')[i]; synu.NetBust = fm["NetBust"].Split(',')[i]; synu.FinishedBust = Convert.ToDecimal(fm["FinishedBust"].Split(',')[i]); synu.InWaist = Convert.ToDecimal(fm["InWaist"].Split(',')[i]); synu.FinishedHem_NoFork = Convert.ToDecimal(fm["FinishedHem_NoFork"].Split(',')[i]); synu.SleeveWidth = Convert.ToDecimal(fm["SleeveWidth"].Split(',')[i]); synu.ShoulderWidth = Convert.ToDecimal(fm["ShoulderWidth"].Split(',')[i]); synu.Sleecve_Show = fm["FinishedHem_NoFork"].Split(',')[i]; synu.Size_Code = fm["Size_Code"]; XF_SY_NU_ChiMa.Add(synu); } else { XF_SY_NU_CodeSizeDto synu = XF_SY_NU_ChiMa.GetOne(T => T.Id == upid); synu.Height = Convert.ToDecimal(fm["Height"].Split(',')[i]); synu.FrontLength = fm["FrontLength"].Split(',')[i]; synu.NetBust = fm["NetBust"].Split(',')[i]; synu.FinishedBust = Convert.ToDecimal(fm["FinishedBust"].Split(',')[i]); synu.InWaist = Convert.ToDecimal(fm["InWaist"].Split(',')[i]); synu.FinishedHem_NoFork = Convert.ToDecimal(fm["FinishedHem_NoFork"].Split(',')[i]); synu.SleeveWidth = Convert.ToDecimal(fm["SleeveWidth"].Split(',')[i]); synu.ShoulderWidth = Convert.ToDecimal(fm["ShoulderWidth"].Split(',')[i]); synu.Sleecve_Show = fm["FinishedHem_NoFork"].Split(',')[i]; XF_SY_NU_ChiMa.Update(synu); } } break; case "XF_KZ_NAN": case "XF_KZ_NU": int count4 = fm["DZ_HipLength_CP"].Split(',').Count(); List <XF_KZ_CodeSizeDto> xfkznulist = new List <XF_KZ_CodeSizeDto>(); for (int i = 0; i < count4; i++) { int upid = 0; if (!int.TryParse(fm["ID"].Split(',')[i], out upid)) { XF_KZ_CodeSizeDto xfkz = new XF_KZ_CodeSizeDto(); xfkz.Code = fm["Code"].Split(',')[i]; xfkz.DZ_HipLength_CP = Convert.ToDecimal(fm["DZ_HipLength_CP"].Split(',')[i]); xfkz.SZ_HipLength_CP = Convert.ToDecimal(fm["SZ_HipLength_CP"].Split(',')[i]); xfkz.Crosspiece = Convert.ToDecimal(fm["Crosspiece"].Split(',')[i]); xfkz.LegWidth_UnderTheWaves = Convert.ToDecimal(fm["LegWidth_UnderTheWaves"].Split(',')[i]); xfkz.FrontRise_EvenWaist = Convert.ToDecimal(fm["FrontRise_EvenWaist"].Split(',')[i]); xfkz.AfterTheWaves_EvenWaist = Convert.ToDecimal(fm["AfterTheWaves_EvenWaist"].Split(',')[i]); xfkz.NetHip = fm["NetHip"].Split(',')[i]; xfkz.CP_WaistWidth = fm["CP_WaistWidth"].Split(',')[i]; xfkz.NetWaist = fm["NetWaist"].Split(',')[i]; xfkz.Size_Code = fm["Size_Code"]; XF_KZ_Service.Add(xfkz); } else { XF_KZ_CodeSizeDto xfkz = XF_KZ_Service.GetOne(T => T.Id == upid); xfkz.Code = fm["Code"].Split(',')[i]; xfkz.DZ_HipLength_CP = Convert.ToDecimal(fm["DZ_HipLength_CP"].Split(',')[i]); xfkz.SZ_HipLength_CP = Convert.ToDecimal(fm["SZ_HipLength_CP"].Split(',')[i]); xfkz.Crosspiece = Convert.ToDecimal(fm["Crosspiece"].Split(',')[i]); xfkz.LegWidth_UnderTheWaves = Convert.ToDecimal(fm["LegWidth_UnderTheWaves"].Split(',')[i]); xfkz.FrontRise_EvenWaist = Convert.ToDecimal(fm["FrontRise_EvenWaist"].Split(',')[i]); xfkz.AfterTheWaves_EvenWaist = Convert.ToDecimal(fm["AfterTheWaves_EvenWaist"].Split(',')[i]); xfkz.NetHip = fm["NetHip"].Split(',')[i]; xfkz.CP_WaistWidth = fm["CP_WaistWidth"].Split(',')[i]; xfkz.NetWaist = fm["NetWaist"].Split(',')[i]; XF_KZ_Service.Update(xfkz); } } int IsKc = 0; for (int i = 0; i < fm.AllKeys.Length; i++) { if (fm.AllKeys[i] == "HK_Height") { IsKc++; } } if (IsKc > 0) { int hkCount = fm["HK_Height"].Split(',').Count(); List <HeightKuChangDto> HKList = new List <HeightKuChangDto>(); for (int i = 0; i < hkCount; i++) { HeightKuChangDto dto = new HeightKuChangDto(); dto.Id = Convert.ToInt32(fm["HK_Id"].Split(',')[i]); dto.Height = Convert.ToDouble(fm["HK_Height"].Split(',')[i]); dto.KuChang = Convert.ToDouble(fm["HK_KuChang"].Split(',')[i]); dto.Size_Code = fm["Size_Code"]; HKList.Add(dto); } } break; default: break; } return(Json(new { state = 1, msg = "" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { state = -1, msg = ex.Message }, JsonRequestBehavior.AllowGet)); } }