Exemplo n.º 1
0
        //上传西服裤子尺码表
        public bool Import_XF_KZ(DataTable table, string Size_Code, out string errmsg)
        {
            try
            {
                List <XF_KZ_CodeSizeDto> tszie_list = new List <XF_KZ_CodeSizeDto>();

                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("..", ".");
                        }

                        if (row[a].ToString().IndexOf("null") > 0)
                        {
                            row[a] = row[a].ToString().Replace("null", "0");
                        }
                        if (string.IsNullOrEmpty(row[a].ToString()))
                        {
                            row[a] = 0;
                        }
                    }

                    row.EndEdit();
                    #endregion
                }

                foreach (DataRow item in table.Rows)
                {
                    XF_KZ_CodeSizeDto tszie = new XF_KZ_CodeSizeDto();
                    tszie.Code = item["Code"].ToString();
                    decimal ty = 0;
                    if (decimal.TryParse(item["DZ_HipLength_CP"].ToString(), out ty))
                    {
                        tszie.DZ_HipLength_CP = ty;
                    }
                    else
                    {
                        tszie.DZ_HipLength_CP = 0;
                    }

                    if (decimal.TryParse(item["SZ_HipLength_CP"].ToString(), out ty))
                    {
                        tszie.SZ_HipLength_CP = ty;
                    }
                    else
                    {
                        tszie.SZ_HipLength_CP = 0;
                    }

                    if (decimal.TryParse(item["Crosspiece"].ToString(), out ty))
                    {
                        tszie.Crosspiece = ty;
                    }
                    else
                    {
                        tszie.Crosspiece = 0;
                    }

                    if (decimal.TryParse(item["LegWidth_UnderTheWaves"].ToString(), out ty))
                    {
                        tszie.LegWidth_UnderTheWaves = ty;
                    }
                    else
                    {
                        tszie.LegWidth_UnderTheWaves = 0;
                    }

                    if (decimal.TryParse(item["FrontRise_EvenWaist"].ToString(), out ty))
                    {
                        tszie.FrontRise_EvenWaist = ty;
                    }
                    else
                    {
                        tszie.FrontRise_EvenWaist = 0;
                    }

                    if (decimal.TryParse(item["AfterTheWaves_EvenWaist"].ToString(), out ty))
                    {
                        tszie.AfterTheWaves_EvenWaist = ty;
                    }
                    else
                    {
                        tszie.AfterTheWaves_EvenWaist = 0;
                    }

                    tszie.NetHip         = item["NetHip"].ToString();
                    tszie.CP_WaistWidth  = item["CP_WaistWidth"].ToString();
                    tszie.Height         = Convert.ToDecimal(item["Height"]);
                    tszie.LongPants      = item["LongPants"].ToString();
                    tszie.NetWaist       = item["NetWaist"].ToString();
                    tszie.Size_Code      = Size_Code;
                    tszie.CreateDateTime = DateTime.Now;
                    tszie.Status         = 1;
                    tszie_list.Add(tszie);
                }

                XF_KZ_Service.Add(tszie_list);

                errmsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                errmsg = ex.Message;
                return(false);
            }
        }
Exemplo n.º 2
0
        public JsonResult Examine(string Action)
        {
            using (var db = new MySqlServer())
                try
                {
                    List <Examine> list = new List <Examine>();
                    switch (Action)
                    {
                    case "XF_SY_NAN":

                        var qudate = XF_SY_NAN_ChiMa.Query(c => c.Status == 1, o => o.Id, false);


                        foreach (var item in qudate.GroupBy(it => it.Size_Code).Select(s => new { CreateDateTime = s.Max(l => l.CreateDateTime), Size_Code = s.Key }))
                        {
                            Examine ex = new Examine();

                            ex.CreateTime = item.CreateDateTime.ToString("yyyy-MM-dd");
                            ex.Code       = item.Size_Code;
                            list.Add(ex);
                        }

                        return(Json(new { state = 1, msg = list }, JsonRequestBehavior.AllowGet));

                    case "XF_SY_NU":

                        var qudatenu = XF_SY_NU_ChiMa.Query(c => c.Status == 1, o => o.Id, false);

                        foreach (var item in qudatenu.GroupBy(it => it.Size_Code).Select(s => new { CreateDateTime = s.Max(l => l.CreateDateTime), Size_Code = s.Key }))
                        {
                            Examine ex = new Examine();

                            ex.CreateTime = item.CreateDateTime.ToString("yyyy-MM-dd");
                            ex.Code       = item.Size_Code;
                            list.Add(ex);
                        }

                        return(Json(new { state = 1, msg = list }, JsonRequestBehavior.AllowGet));

                    case "XF_KZ_NAN":

                        var qudatekznan = XF_KZ_Service.Query(c => c.Status == 1, o => o.Id, false);

                        foreach (var item in qudatekznan.GroupBy(it => it.Size_Code).Select(s => new { CreateDateTime = s.Max(l => l.CreateDateTime), Size_Code = s.Key }))
                        {
                            Examine ex = new Examine();

                            ex.CreateTime = item.CreateDateTime.ToString("yyyy-MM-dd");
                            ex.Code       = item.Size_Code;
                            list.Add(ex);
                        }

                        return(Json(new { state = 1, msg = list }, JsonRequestBehavior.AllowGet));

                    case "XF_KZ_NU":

                        var qudatekznu = XF_KZ_Service.Query(c => c.Status == 1, o => o.Id, false);

                        foreach (var item in qudatekznu.GroupBy(it => it.Size_Code).Select(s => new { CreateDateTime = s.Max(l => l.CreateDateTime), Size_Code = s.Key }))
                        {
                            Examine ex = new Examine();

                            ex.CreateTime = item.CreateDateTime.ToString("yyyy-MM-dd");
                            ex.Code       = item.Size_Code;
                            list.Add(ex);
                        }

                        return(Json(new { state = 1, msg = list }, JsonRequestBehavior.AllowGet));

                    default:
                        throw new Exception("系统出错:没有对应的Action");
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { state = -1, msg = ex.Message }, JsonRequestBehavior.AllowGet));
                }
        }
Exemplo n.º 3
0
        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));
                }
        }