Beispiel #1
0
        public BaseResult CheckImportInfo(Tb_Khfl_Import model, List<Tb_Khfl> dbList)
        {
            BaseResult br = new BaseResult();
            if (string.IsNullOrEmpty(model.mc))
            {
                br.Success = false;
                br.Data = "mc";
                br.Message.Add("名称不能为空");
                return br;
            }
            //if (string.IsNullOrEmpty(model.bm))
            //{
            //    br.Success = false;
            //    br.Data = "bm";
            //    br.Message.Add("编码不能为空");
            //    return br;
            //}

            if (dbList != null)
            {
                if (dbList.Where(d => d.mc == model.mc && d.id_farther == "0").Count() > 0)
                {
                    br.Success = false;
                    br.Data = "mc";
                    br.Message.Add("名称重复");
                    return br;
                }
                //else if (dbList.Where(d => d.bm == model.bm && d.id_farther == "0").Count() > 0)
                //{
                //    br.Success = false;
                //    br.Data = "bm";
                //    br.Message.Add("编码重复");
                //    return br;
                //}
                else
                {
                    var st = new Tb_Khfl();
                    st.bm = model.bm;
                    st.mc = model.mc;
                    st.id = Guid.NewGuid().ToString();
                    st.path = "/0/" + st.id;
                    st.id_farther = "0";
                    st.flag_delete = (byte)Enums.FlagDelete.NoDelete;
                    st.rq_edit = st.rq_create = DateTime.Now;
                    st.id_edit = st.id_create = "";
                    st.id_masteruser = "";
                    dbList.Add(st);
                }
            }


            br.Success = true;
            return br;
        }
Beispiel #2
0
        /// <summary>
        /// 类型转换
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        private List <Tb_Khfl_Import> TurnShopSPImportList(DataTable table)
        {
            List <Tb_Khfl_Import> list = new List <Tb_Khfl_Import>();

            foreach (DataRow item in table.Rows)
            {
                Tb_Khfl_Import model = new Tb_Khfl_Import();
                model.bm     = item["编码或条码"] == null ? "" : item["编码或条码"].ToString();
                model.mc     = item["名称"] == null ? "" : item["名称"].ToString();
                model.father = item["上级名称"] == null ? "" : item["上级名称"].ToString();
                model.bz     = item["备注"] == null ? "" : item["备注"].ToString();
                list.Add(model);
            }
            return(list);
        }