Beispiel #1
0
        public ActionResult GetAllSuppliers(string onepagecount = "10", string suppliername = "", string pagenum = "1")
        {
            ComResult com = new ComResult();

            if (!Regex.IsMatch(suppliername, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(suppliername))
            {
                com.Msg   = "供应商名称不能包含特殊字符";
                com.State = 0;
                return(Json(com));
            }
            int totil     = 0;
            int totilpage = 0;
            List <base_supplier>     suppliers     = _service.SearchSupplier(Convert.ToInt32(pagenum), Convert.ToInt32(onepagecount), suppliername, out totil, out totilpage);
            List <SupplierViewModel> suppliersView = new List <SupplierViewModel>();

            foreach (var ea in suppliers)
            {
                SupplierViewModel model = new SupplierViewModel();
                model.ID          = ea.supp_id.ToString();
                model.supp_code   = ea.supp_code;
                model.supp_name   = ea.supp_name;
                model.supp_url    = ea.supp_url;
                model.supp_remark = ea.remark;
                model.CreateTime  = ea.create_time.ToString();
                suppliersView.Add(model);
            }
            SupplierNview mylist = new SupplierNview();

            mylist.supplist   = suppliersView;
            mylist.totil      = totil.ToString();
            mylist.totilcount = totilpage.ToString();
            com.State         = 1;
            com.DataResult    = mylist;
            return(Json(com));
        }
Beispiel #2
0
        public async Task <ComResult <Template> > Modify(Template model)
        {
            var result = new ComResult <Template>();

            if (model.Id == default(int))
            {
                model.CreateTime = model.ModifyTime = DateTime.Now;
                model.PrintCount = 0;
                var entity = await this.DBContext.Templates.AddAsync(model);

                result.Data = entity.Entity;
            }
            else
            {
                var entry = this.DBContext.Templates.Attach(model);
                entry.Property(w => w.ModifyTime).CurrentValue = DateTime.Now;
                entry.State = EntityState.Modified;
                result.Data = entry.Entity;
            }
            var refCount = await this.DBContext.SaveChangesAsync();

            result.Success = refCount > 0;
            result.Msg     = "操作成功";
            result.Code    = "0";
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// 判断款号是否存在
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public ActionResult PcodeIsEixt(string code)
        {
            ComResult com = new ComResult();

            if (string.IsNullOrEmpty(code))
            {
                com.State = 0;
                com.Msg   = "款号不能为空";
                return(Json(com));
            }
            //if (!Regex.IsMatch(code, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(code))
            //{
            //    com.Msg = "款号不能包含特殊字符";
            //    com.State = 0;
            //    return Json(com);
            //}
            bool isexit = _service.PcodeIsExit(code);

            if (isexit)
            {
                com.Msg   = "款号已经存在";
                com.State = 0;
                return(Json(com));
            }
            else
            {
                com.Msg   = "该款号可以使用";
                com.State = 1;
                return(Json(com));
            }
        }
Beispiel #4
0
        public ActionResult GetDeclarationExcel(string dhlcode, string zhuanyuncode)
        {
            ComResult com = new ComResult();

            if (string.IsNullOrEmpty(dhlcode) || string.IsNullOrEmpty(zhuanyuncode))
            {
                com.State = 0;
                com.Msg   = "DHL单号和转运单号不能为空";
                return(Json(com));
            }
            string filename = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            string path     = "/DownExcel/";
            string fullpath = Server.MapPath(path) + filename;
            bool   isok     = _service.IsExitZY(zhuanyuncode);

            if (!isok)
            {
                com.State = 0;
                com.Msg   = "转运单号不存在";
                return(Json(com));
            }
            try
            {
                string excelurl = _service.GetDeclarationExcelUrl(dhlcode, zhuanyuncode, fullpath);
                com.State = 1;
                com.URL   = "../DownExcel/" + filename;
                return(Json(com));
            }
            catch (Exception ex)
            {
                com.State = 0;
                com.Msg   = "生成失败原因:" + ex.Message;
                return(Json(com));
            }
        }
Beispiel #5
0
        //
        public ActionResult AddProductSupplier(string supplier, int proid)
        {
            ComResult com = new ComResult();

            try
            {
                base_prod_supp_rel suppid = _service.AddProductSupplier(supplier, proid);
                if (null == suppid)
                {
                    com.Msg   = "添加失败";
                    com.State = 0;
                    return(Json(com));
                }
                else
                {
                    com.Msg        = "";
                    com.State      = 1;
                    com.DataResult = suppid;
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.Msg   = ex.Message;
                com.State = 0;
                return(Json(com));
            }
        }
Beispiel #6
0
        public ActionResult DeleteProClassfy(string id)
        {
            ComResult res = new ComResult();

            try
            {
                if (!Regex.IsMatch(id, @"^\d+$"))
                {
                    res.Msg   = "ID只能是数字,且非负";
                    res.State = 0;
                    return(Json(res));
                }
                bool isok = _service.DeleteProClassfy(Convert.ToInt32(id));
                if (isok)
                {
                    res.Msg   = "删除成功";
                    res.URL   = "/Product/Index";
                    res.State = 1;
                    return(Json(res));
                }
                else
                {
                    res.Msg   = "删除失败";
                    res.State = 0;
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                res.Msg   = ex.ToString();
                res.State = 0;
                return(Json(res));
            }
        }
Beispiel #7
0
        public ActionResult DeleteProductSupplier(int relid, int proid)
        {
            ComResult com = new ComResult();

            try
            {
                bool isok = _service.DeleteProductSupplier(relid, proid);
                if (!isok)
                {
                    com.Msg   = "删除失败";
                    com.State = 0;
                    return(Json(com));
                }
                else
                {
                    com.Msg   = "";
                    com.State = 1;
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.Msg   = ex.Message;
                com.State = 0;
                return(Json(com));
            }
        }
Beispiel #8
0
        public ActionResult DeleteSupplier(string id)
        {
            ComResult res = new ComResult();

            if (!Regex.IsMatch(id, @"^\d+$"))
            {
                res.Msg   = "ID只能是数字,且非负";
                res.State = 0;
                return(Json(res));
            }
            bool isok = _service.DeleteSupplier(Convert.ToInt32(id));

            if (isok)
            {
                res.Msg   = "删除成功!";
                res.State = 1;
                res.URL   = "/Supplier/SerachSupplier";
                return(Json(res));
            }
            else
            {
                res.Msg   = "删除失败!";
                res.State = 0;
                return(Json(res));
            }
        }
Beispiel #9
0
        public ActionResult UpdateSKU(int codeID, string skucode)
        {
            ComResult com = new ComResult();

            try
            {
                if (codeID <= 0)
                {
                    com.State = 0;
                    com.Msg   = "SKU ID获取失败";
                    return(Json(com));
                }
                bool detail = _service.UpdateSKU(codeID, skucode);
                if (detail)
                {
                    com.Msg   = "更新成功";
                    com.State = 1;
                    return(Json(com));
                }
                else
                {
                    com.Msg   = "更新失败";
                    com.State = 0;
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.State = 0;
                com.Msg   = "产品详情获取失败" + ex.ToString();
                return(Json(com));
            }
        }
Beispiel #10
0
        public ActionResult UploadMainImage(int proID)
        {
            ComResult com = new ComResult();

            try
            {
                string[] extends = { ".jpg", ".png", ".gif" };
                var      files   = Request.Files;
                if (files != null && files.Count == 1)//单个文件
                {
                    HttpPostedFileBase fileitem     = files[0];
                    string             strExtension = Path.GetExtension(fileitem.FileName);
                    if (!extends.Contains(strExtension))
                    {
                        com.Msg   = "文件格式不正确,必须是图片文件";
                        com.State = 0;
                        return(Json(com));
                    }
                    string filePath   = "/upload/image/product/" + DateTime.Now.ToString("yyyyMM") + "/";
                    string uploadpath = Server.MapPath(filePath);
                    if (Directory.Exists(uploadpath) == false)//如果不存在就创建file文件夹
                    {
                        Directory.CreateDirectory(uploadpath);
                    }
                    string newfilename = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(fileitem.FileName);
                    string fFullDir    = uploadpath + newfilename;
                    fileitem.SaveAs(fFullDir); //保存到硬盘
                    //2.保存到数据库
                    bool isok = _service.SetProMainImg(filePath + newfilename, proID);
                    if (!isok)
                    {
                        com.Msg   = "上传失败";
                        com.State = 0;
                        return(Json(com));
                    }
                    else
                    {
                        com.Msg   = "上传成功";
                        com.State = 1;
                        com.URL   = filePath + newfilename;
                        return(Json(com));
                    }
                }
                else
                {
                    com.Msg   = "不能上传多个文件";
                    com.State = 0;
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.Msg   = "上传失败" + ex.Message;
                com.State = 0;
                return(Json(com));
            }
        }
Beispiel #11
0
        /// <summary>
        /// 添加或者更新用户信息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="state">0代表修改密码1代表删除用户2代表禁用启用用户3代表添加</param>
        /// <returns></returns>
        public ComResult AddOrUpdateUserInfo(base_users model, int state)
        {
            ComResult result = new ComResult();

            using (var db = SugarDao.GetInstance(LoginUser.GetConstr()))
            {
                if (model.user_id > 0)
                {    //判断用户名是否存在
                    var userModel = db.Queryable <base_users>().Where(a => a.user_id == model.user_id).ToList();
                    if (userModel == null || userModel.Count() <= 0)
                    {
                        result.State = 0;
                        result.Msg   = "用户不存在";
                        return(result);
                    }
                    switch (state)
                    {
                    case 0:
                        db.Update <base_users>(new { user_pwd = model.user_pwd, real_name = model.real_name }, a => a.user_id == model.user_id);
                        break;

                    case 1:
                        db.Update <base_users>(new { del_flag = model.del_flag }, a => a.user_id == model.user_id);
                        break;

                    case 2:
                        db.Update <base_users>(new { user_status = model.user_status }, a => a.user_id == model.user_id);
                        break;;
                    }
                    result.State = 1;
                    return(result);
                }
                else
                {
                    //判断用户名是否存在
                    var userModel = db.Queryable <base_users>().Where(a => a.user_name == model.user_name).ToList();
                    if (userModel != null && userModel.Count() > 0)
                    {
                        result.State = 0;
                        result.Msg   = "用户已经存在";
                        return(result);
                    }
                    model.create_time    = DateTime.Now;
                    model.edit_time      = DateTime.Now;
                    model.del_flag       = true;
                    model.user_status    = true;
                    model.create_user_id = LoginUser.Current.user_id;
                    model.net_no         = 1;
                    model.emp_no         = 1;
                    result.State         = 1;
                    result.DataResult    = db.InsertOrUpdate <base_users>(model);
                    return(result);
                }
            }
        }
Beispiel #12
0
        public ActionResult GetLSpage(int shopID)//string pagenum, string onepagecount,
        {
            ComResult com = new ComResult();

            try
            {
                //if (!Regex.IsMatch(pagenum, @"^\+?[1-9][0-9]*$") && !string.IsNullOrEmpty(pagenum))
                //{
                //    com.Msg = "只能是数字";
                //    com.State = 0;
                //    return Json(com);
                //}
                //if (!Regex.IsMatch(onepagecount, @"^\+?[1-9][0-9]*$") && !string.IsNullOrEmpty(onepagecount))
                //{
                //    com.Msg = "只能是数字";
                //    com.State = 0;
                //    return Json(com);
                //}
                if (!Regex.IsMatch(shopID.ToString(), @"^\+?[1-9][0-9]*$") && !string.IsNullOrEmpty(shopID.ToString()))
                {
                    com.Msg   = "只能是数字";
                    com.State = 0;
                    return(Json(com));
                }
                if (string.IsNullOrEmpty(shopID.ToString()))
                {
                    com.Msg   = "没有选择店铺";
                    com.State = 0;
                    return(Json(com));
                }
                int totil = 0;
                //int totilpage = 0;
                string     exmsg    = string.Empty;
                var        PSKUlist = _service.SearchLStable(shopID, out totil, out exmsg);
                MyPageList pagelist = new MyPageList();
                pagelist.count = totil;
                pagelist.list  = PSKUlist;
                //pagelist.pageCount = packgecount;
                //pagelist.pageIndex = pageIndex;
                //pagelist.pageSize = pageSize;
                return(Json(pagelist));

                //LSOrderViewmodel mypkskulist = new LSOrderViewmodel();
                //mypkskulist.PSKUlist = PSKUlist;
                //mypkskulist.totilcount = totil.ToString();
                ////mypkskulist.totilpage = totilpage.ToString();
                //com.State = 1;
                //com.DataResult = mypkskulist;
                //return Json(com);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #13
0
        /// <summary>
        /// 登入用户验证
        /// </summary>
        /// <param name="net_no">网点</param>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="ischeck">是否没主库登入</param>
        /// <returns></returns>
        public ComResult VerifyUserLogin(long net_no, string username, string password, bool ischeck)
        {
            ComResult result = new ComResult();

            //用户是否访问的为主库
            if (ischeck)
            {
                //访问主库
                return(ZKlogin(new tbl_users()
                {
                    user_pwd = password, user_name = username, net_no = net_no
                }));
            }
            else
            {
                //访问从库

                //通过网点查询数据库信息
                var dbinfo = new tbl_sys_db_config();
                try
                {
                    using (var db = SugarDao.GetInstance(SugarDao.ConnectionGloablString))
                    {
                        dbinfo = db.Queryable <tbl_sys_db_config>()
                                 .JoinTable <tbl_sys_net_config>((s1, s2) => s1.db_conf_id == s2.db_conf_id, JoinType.Inner)
                                 .Where <tbl_sys_net_config>((s1, s2) => s2.net_no == net_no).Select("s1.*").SingleOrDefault();
                    }
                }
                catch (Exception e)
                {
                    result.State = 0;
                    result.Msg   = e.Message;
                    return(result);
                }
                //判断网点是否存在
                if (dbinfo == null || dbinfo.db_name == "")
                {
                    result.State = 0;
                    result.Msg   = "公司网点不存在";
                    return(result);
                }
                else
                {
                    //获取从库的信息  EncodeHepler.DecDataBasePass(dbinfo.login_pwd, SystemConfig.encDataBasePassword)
                    var connetionstr = "server=" + dbinfo.ip_address + ";uid=" + dbinfo.login_name + ";pwd=" + dbinfo.login_pwd + ";database=" + dbinfo.db_name + "";
                    //将从库链接字符串记录缓存中
                    SessionHelper.Add(SystemConfig.connectionStringKey, connetionstr, SystemConfig.loginExpireTime);
                    //从库登录
                    return(CKlogin(new base_users()
                    {
                        user_pwd = password, user_name = username, net_no = net_no
                    }, connetionstr));
                }
            }
        }
Beispiel #14
0
        public ActionResult Logout()
        {
            CookieHelper.ClearCookie("username");
            CookieHelper.ClearCookie("password");
            CookieHelper.ClearCookie("remember");
            CookieHelper.ClearCookie("tockenid");
            ComResult com = new ComResult();

            com.State = 1;
            com.URL   = "/login/login";
            return(Json(com));
        }
Beispiel #15
0
        /// <summary>
        /// 插入正式库
        /// </summary>
        /// <param name="shopID"></param>
        /// <param name="platformID"></param>
        /// <returns></returns>
        public ActionResult InsertOrder(string shopID, string platformID, List <base_LSorder> list)
        {
            ComResult com = new ComResult();

            try
            {
                if (!Regex.IsMatch(shopID, @"^\+?[1-9][0-9]*$") && !string.IsNullOrEmpty(shopID))
                {
                    com.Msg   = "只能是数字";
                    com.State = 0;
                    return(Json(com));
                }
                if (string.IsNullOrEmpty(shopID))
                {
                    com.Msg   = "没有选择店铺";
                    com.State = 0;
                    return(Json(com));
                }
                if (!Regex.IsMatch(platformID, @"^\+?[1-9][0-9]*$") && !string.IsNullOrEmpty(shopID))
                {
                    com.Msg   = "只能是数字";
                    com.State = 0;
                    return(Json(com));
                }
                if (string.IsNullOrEmpty(platformID))
                {
                    com.Msg   = "没有选择平台";
                    com.State = 0;
                    return(Json(com));
                }
                int lvcount = 0;
                int count   = _service.InsertOrder(Convert.ToInt32(platformID), Convert.ToInt32(shopID), list, out lvcount);
                if (count > 0)
                {
                    com.Msg   = "解析成功,一共插入" + count.ToString() + "条订单数据,过滤了" + lvcount + "条数数据,请查看并删除过滤的数据!";
                    com.State = 1;
                    return(Json(com));
                }
                else
                {
                    com.Msg   = "解析失败";
                    com.State = 0;
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.Msg   = ex.Message;
                com.State = 0;
                return(Json(com));
            }
        }
Beispiel #16
0
        public ActionResult AddSupplier(string suppname, string remark, string suppurl)
        {
            ComResult res = new ComResult();

            if (!Regex.IsMatch(suppname, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$"))
            {
                res.Msg   = "供应商名不能有非法字符";
                res.State = 0;
                return(Json(res));
            }
            if (!Regex.IsMatch(suppurl, @"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"))
            {
                res.Msg   = "链接不是有效地址!";
                res.State = 0;
                return(Json(res));
            }
            if (!Regex.IsMatch(remark, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(remark))
            {
                res.Msg   = "备注不能有非法字符";
                res.State = 0;
                return(Json(res));
            }
            base_supplier supp = new base_supplier();

            supp.create_user_id = 1;
            supp.del_flag       = true;
            supp.supp_name      = suppname;
            supp.supp_url       = suppurl;
            supp.remark         = remark;
            supp.supp_code      = "GYS" + "001";
            supp.is_grade       = true;
            supp.purc_mode      = 1;
            supp.purc_priority  = 1;
            supp.purc_sourceid  = 1;
            supp.create_time    = DateTime.Now;
            bool isok = _service.AddSupplier(supp);

            if (isok)
            {
                res.Msg   = "添加成功!";
                res.State = 1;
                res.URL   = "/Supplier/SerachSupplier";
                return(Json(res));
            }
            else
            {
                res.Msg   = "添加失败!";
                res.State = 0;
                return(Json(res));
            }
        }
Beispiel #17
0
        /// <summary>
        /// 得到产品列表
        /// </summary>
        /// <param name="pagenum">几页</param>
        /// <param name="onepagecount">每页数据</param>
        /// <param name="statue">审核,正式,回收站</param>
        /// <returns></returns>
        public ActionResult GetProcudtListByCondtion(string pageIndex, string onepagecount, string status, string prostyle, string proskucode, string prodevelpoer)
        {
            ComResult res = new ComResult();

            try
            {
                int totil     = 0;
                int totilpage = 0;
                List <ProcudtViewModel> prolist = _service.Getprolist(Convert.ToInt32(pageIndex), Convert.ToInt32(onepagecount), out totil, out totilpage, Convert.ToInt32(status), prostyle, proskucode, prodevelpoer);

                //List<ProcudtViewModel> tempCard = prolist.Distinct(new LinqCompare()).ToList();
                if (prolist == null)
                {
                    res.State = 0;
                    res.Msg   = "查询失败";
                    return(Json(res));
                }
                List <ProductNViewmodel> nprolist = new List <ProductNViewmodel>();
                foreach (var item in prolist)
                {
                    ProductNViewmodel aa = new ProductNViewmodel();
                    aa.create_time    = item.create_time;
                    aa.pic_url        = item.pic_url;
                    aa.price_cn       = item.price_cn;
                    aa.prod_developer = item.prod_developer;
                    aa.prod_id        = item.prod_id;
                    aa.prod_property  = Enum.GetName(typeof(Productstyle), Convert.ToInt32(item.prod_property));
                    aa.prod_status    = Enum.GetName(typeof(ProductStatus), Convert.ToInt32(item.prod_status));
                    aa.prod_style     = item.prod_style;
                    aa.prod_title     = item.prod_title;
                    aa.remark         = item.remark;
                    nprolist.Add(aa);
                }
                PageList list = new PageList();//
                list.objlist   = nprolist;
                list.pageCount = totilpage;
                list.pageIndex = Convert.ToInt32(pageIndex);
                list.pageSize  = Convert.ToInt32(onepagecount);
                list.count     = totil;
                list.State     = 1;
                return(Json(list));
            }
            catch (Exception ex)
            {
                res.State = 0;
                res.Msg   = "查询失败" + ex.ToString();
                return(Json(res));
            }
        }
Beispiel #18
0
        public ActionResult AddNewProduct(string code, string proname, string bgname, string bgcode, string bgprice, string weight, string price, string remark, string clasf, string profly, string promodel, string prosize, List <string> skulist)
        {
            ComResult com = new ComResult();

            try
            {
                if (string.IsNullOrEmpty(code))
                {
                    com.State = 0;
                    com.Msg   = "款号不能为空";
                    return(Json(com));
                }
                //if (!Regex.IsMatch(code, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(code))
                //{
                //    com.Msg = "款号不能包含特殊字符";
                //    com.State = 0;
                //    return Json(com);
                //}
                if (skulist.Count <= 0)
                {
                    com.Msg   = "SKU列表为空";
                    com.State = 0;
                    return(Json(com));
                }
                bool isok = _service.InsertProdcut(code, proname, bgname, bgcode, bgprice, weight, price, remark, clasf, profly, promodel, prosize, skulist);
                if (isok)
                {
                    com.Msg   = "添加成功";
                    com.State = 0;
                    return(Json(com));
                }
                else
                {
                    com.Msg   = "添加失败";
                    com.State = 0;
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.Msg   = "添加失败:原因" + ex.ToString();
                com.State = 0;
                return(Json(com));
            }
        }
Beispiel #19
0
        public ActionResult ExportReturnPlat(string zhuanyuncode, long express, long shop)
        {
            ComResult com = new ComResult();

            if (string.IsNullOrEmpty(zhuanyuncode))
            {
                com.State = 0;
                com.Msg   = "转运单号不能为空";
                return(Json(com));
            }
            string filename = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            string path     = "/DownExcel/";
            string fullpath = Server.MapPath(path) + filename;
            bool   isok     = _service.IsExitZY(zhuanyuncode);

            if (!isok)
            {
                com.State = 0;
                com.URL   = "转运单号不存在";
                return(Json(com));
            }
            try
            {
                bool isok2 = _service.GetDeclarationDHLExcelUrl(zhuanyuncode, fullpath, express, shop);
                if (isok2)
                {
                    com.State = 1;
                    com.URL   = "../DownExcel/" + filename;
                    return(Json(com));
                }
                else
                {
                    com.State = 0;
                    com.URL   = "生成失败!";
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.State = 0;
                com.Msg   = "生成失败原因:" + ex.Message;
                return(Json(com));
            }
        }
Beispiel #20
0
        public ActionResult UpdateSupplier(string suppname, string remark, string suppurl, string id)
        {
            ComResult res = new ComResult();

            if (!Regex.IsMatch(id, @"^\d+$"))
            {
                res.Msg   = "ID只能是数字,且非负";
                res.State = 0;
                return(Json(res));
            }
            if (!Regex.IsMatch(suppname, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$"))
            {
                res.Msg   = "供应商名不能有非法字符";
                res.State = 0;
                return(Json(res));
            }
            if (!Regex.IsMatch(suppurl, @"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"))
            {
                res.Msg   = "链接不是有效地址!";
                res.State = 0;
                return(Json(res));
            }
            if (!Regex.IsMatch(remark, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(remark))
            {
                res.Msg   = "备注不能有非法字符";
                res.State = 0;
                return(Json(res));
            }
            bool isok = _service.UpdateSupplier(suppname, remark, suppurl, Convert.ToInt32(id));

            if (isok)
            {
                res.Msg   = "更新成功!";
                res.State = 1;
                res.URL   = "/Supplier/SerachSupplier";
                return(Json(res));
            }
            else
            {
                res.Msg   = "更新失败!";
                res.State = 0;
                return(Json(res));
            }
        }
Beispiel #21
0
        public ActionResult GetAllPSkuByShopID(int shopID)
        {
            ComResult com = new ComResult();

            try
            {
                int totil     = 0;
                int totilpage = 0;
                //默认取第一页,每页2000条数据,相当于全部查询出来,和以前的函数兼容
                var PSKUlist = CommService.GetPSKUListByshopID(1, 2000, shopID, out totil, out totilpage);
                com.State      = 1;
                com.DataResult = PSKUlist;
                return(Json(com));
            }
            catch (Exception ex)
            {
                com.State = 0;
                com.Msg   = ex.Message;
                return(Json(com));
            }
        }
Beispiel #22
0
        public ActionResult UpdateProClassfyDel(string proclassfyname, string id) //DeleteProClassfy
        {
            ComResult res = new ComResult();

            try
            {
                if (!Regex.IsMatch(proclassfyname, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(proclassfyname))
                {
                    res.Msg   = "分类名称不能有非法字符";
                    res.State = 0;
                    return(Json(res));
                }
                if (!Regex.IsMatch(id, @"^\d+$"))
                {
                    res.Msg   = "ID只能是数字,且非负";
                    res.State = 0;
                    return(Json(res));
                }
                bool isok = _service.UpdateProclassfyDel(proclassfyname, Convert.ToInt32(id));
                if (isok)
                {
                    res.Msg   = "还原成功";
                    res.URL   = "/Product/Index";
                    res.State = 1;
                    return(Json(res));
                }
                else
                {
                    res.Msg   = "还原失败";
                    res.State = 0;
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                res.Msg   = ex.ToString();
                res.State = 0;
                return(Json(res));
            }
        }
Beispiel #23
0
        public ActionResult Getpage(string pagenum, string onepagecount)
        {
            ComResult com = new ComResult();

            if (!Regex.IsMatch(pagenum, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(pagenum))
            {
                com.Msg   = "页数不正确";
                com.State = 0;
                return(Json(com));
            }

            if (!Regex.IsMatch(onepagecount, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(onepagecount))
            {
                com.Msg   = "每页数量不正确";
                com.State = 0;
                return(Json(com));
            }
            int    totil     = 0;
            int    totilpage = 0;
            string exmsg     = string.Empty;
            List <base_productclass> mylist = _service.Getpages(Convert.ToInt32(pagenum), Convert.ToInt32(onepagecount), out totil, out totilpage, out exmsg);

            if (!string.IsNullOrEmpty(exmsg))
            {
                com.Msg   = exmsg;
                com.State = 0;
                return(Json(com));
            }
            else
            {
                ProductClassfyViewModel mylistview = new ProductClassfyViewModel();
                mylistview.supplist   = mylist;
                mylistview.totil      = totil.ToString();
                mylistview.totilcount = totilpage.ToString();
                com.DataResult        = mylistview;
                com.State             = 1;
                return(Json(com));
            }
        }
Beispiel #24
0
        public ActionResult UpdateNewProduct(string code, string proname, string bgname, string bgcode, string bgprice, string weight, string price, string remark, string profly, string promodel, string prosize, int proid, int prostatus, string purchase_url)
        {
            ComResult com = new ComResult();

            try
            {
                if (string.IsNullOrEmpty(code))
                {
                    com.State = 0;
                    com.Msg   = "款号不能为空";
                    return(Json(com));
                }
                //if (!Regex.IsMatch(code, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(code))
                //{
                //    com.Msg = "款号不能包含特殊字符";
                //    com.State = 0;
                //    return Json(com);
                //}
                bool isok = _service.UpdateProdcut(code, proname, bgname, bgcode, bgprice, weight, price, remark, profly, promodel, prosize, proid, prostatus, purchase_url);
                if (isok)
                {
                    com.Msg   = "更新成功";
                    com.State = 0;
                    return(Json(com));
                }
                else
                {
                    com.Msg   = "更新失败";
                    com.State = 0;
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.Msg   = "更新失败:原因" + ex.ToString();
                com.State = 0;
                return(Json(com));
            }
        }
Beispiel #25
0
        public ActionResult UpdateLSSKU(string shopID, string id, string clientname, string sku, string num, string telephone, string phone, string address)
        {
            ComResult com = new ComResult();

            try
            {
                if (!Regex.IsMatch(shopID, @"^\+?[1-9][0-9]*$") && !string.IsNullOrEmpty(shopID))
                {
                    com.Msg   = "只能是数字";
                    com.State = 0;
                    return(Json(com));
                }
                if (string.IsNullOrEmpty(shopID))
                {
                    com.Msg   = "没有选择店铺";
                    com.State = 0;
                    return(Json(com));
                }
                bool isok = _service.UpdateLStable(Convert.ToInt32(shopID), Convert.ToInt32(id), clientname, sku, num, telephone, phone, address);
                if (isok)
                {
                    com.Msg   = "更新成功";
                    com.State = 1;
                    return(Json(com));
                }
                else
                {
                    com.Msg   = "更新失败";
                    com.State = 0;
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.Msg   = "更新失败" + ex.ToString();
                com.State = 0;
                return(Json(com));
            }
        }
Beispiel #26
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <param name="shopID"></param>
        /// <returns></returns>
        public ActionResult DeleteLs(string id, string shopID)
        {
            ComResult com = new ComResult();

            try
            {
                if (!Regex.IsMatch(shopID, @"^\+?[1-9][0-9]*$") && !string.IsNullOrEmpty(shopID))
                {
                    com.Msg   = "只能是数字";
                    com.State = 0;
                    return(Json(com));
                }
                if (string.IsNullOrEmpty(shopID))
                {
                    com.Msg   = "没有选择店铺";
                    com.State = 0;
                    return(Json(com));
                }
                bool isok = _service.DeleteLStable(Convert.ToInt32(shopID), Convert.ToInt32(id));
                if (isok)
                {
                    com.Msg   = "删除成功";
                    com.State = 1;
                    return(Json(com));
                }
                else
                {
                    com.Msg   = "删除失败";
                    com.State = 0;
                    return(Json(com));
                }
            }
            catch (Exception ex)
            {
                com.Msg   = "删除失败" + ex.ToString();
                com.State = 0;
                return(Json(com));
            }
        }
Beispiel #27
0
        public ActionResult GetProductDetail(int proID)
        {
            ComResult com = new ComResult();

            try
            {
                if (proID <= 0)
                {
                    com.State = 0;
                    com.Msg   = "产品ID获取错误";
                    return(Json(com));
                }
                ProductDetail detail = _service.GetProductDetail(proID);
                com.DataResult = detail;
                com.State      = 1;
                return(Json(com));
            }
            catch (Exception ex)
            {
                com.State = 0;
                com.Msg   = "产品详情获取失败" + ex.ToString();
                return(Json(com));
            }
        }
        /// <summary>
        /// 发送数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="common">发送数据</param>
        /// <param name="data">命令码</param>
        /// <returns></returns>
        public ComResult <RT> Send <T, RT>(int common, T data)
            where T : struct
            where RT : struct
        {
            ComResult <RT> result = new ComResult <RT>();

            try
            {
                //发送命令码
                byte[] commonData = BitConverter.GetBytes(common);
                byte[] sendStruct = MarshalHelper.StructToBytes(data);

                //发送数据
                byte[] sendData = new byte[sendStruct.Length + 11];
                sendData[0] = 0xff;
                sendData[1] = 0x01;
                sendData[2] = 0x00;
                Array.Copy(commonData, 0, sendData, 3, 4);
                sendData[7] = 0x01;
                Array.Copy(BitConverter.GetBytes(sendStruct.Length), 0, sendData, 8, 2);
                Array.Copy(sendStruct, 0, sendData, 10, sendStruct.Length);
                sendData[sendData.Length - 1] = DataCheck(sendData);

                //准备接收缓冲区
                int receiveDataSize = Marshal.SizeOf(typeof(RT));

                //发送数据
                var receiveDate = SendData(sendData, receiveDataSize);

                if (receiveDate[0] == 0xff && receiveDate[2] == 0x01)
                {
                    //校验数据
                    if (receiveDate[receiveDate.Length - 1] != DataCheck(receiveDate))
                    {
                        result.Result = ComResultEnum.VerificationError;
                    }

                    //解析数据
                    int dataLength = BitConverter.ToInt16(receiveDate, 8); //获取数据长度
                    if (dataLength == receiveDataSize)
                    {
                        byte[] dataBytes = new byte[dataLength];
                        Array.Copy(receiveDate, 10, dataBytes, 0, dataLength);
                        result.Data = MarshalHelper.BytesToStruct <RT>(dataBytes);
                    }
                    else
                    {
                        result.Result = ComResultEnum.VerificationError;
                    }
                }
                else
                {
                    result.Result = ComResultEnum.VerificationError;
                }
            }
            catch (Exception ex)
            {
                result.Result = ComResultEnum.TimeOut;
            }

            return(result);
        }
Beispiel #29
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        private ComResult ZKlogin(tbl_users userModel)
        {
            using (var db = SugarDao.GetInstance(SugarDao.ConnectionGloablString))
            {
                ComResult result = new ComResult();
                //验证公司网点
                var singlenet_no = db.Queryable <tbl_users>().SingleOrDefault(c => c.net_no == userModel.net_no);
                if (singlenet_no == null)
                {
                    result.State = 0;
                    result.Msg   = "公司网点不存在";

                    return(result);
                }
                //验证用户名和密码
                var singleuser = db.Queryable <tbl_users>().SingleOrDefault(c => c.user_name == userModel.user_name);
                if (singleuser == null)
                {
                    result.State = 0;
                    result.Msg   = "用户不存在";

                    return(result);
                }
                //密码校验错误次数,超过5次设置10分钟的缓冲时间
                //记录登录错误日志
                var reeoruser = db.Queryable <tbl_user_login_error>().SingleOrDefault(c => c.user_id == singleuser.user_id);
                if (reeoruser != null && reeoruser.check_times > 0 && reeoruser.check_times % 5 == 0 && DateTime.Now <= reeoruser.login_date.AddMinutes(10))
                {
                    result.State = 0;
                    result.Msg   = "密码校验错误次数超过5次,请10分钟后尝试";

                    return(result);
                }
                var usermodel = db.Queryable <tbl_users>().SingleOrDefault(c => c.user_name == userModel.user_name && c.user_pwd == userModel.user_pwd);
                if (usermodel == null)
                {
                    if (reeoruser == null)
                    {
                        db.Insert <tbl_user_login_error>(new tbl_user_login_error()
                        {
                            user_id = singleuser.user_id, check_times = 1, login_date = DateTime.Now
                        });
                    }
                    else
                    {
                        db.Update <tbl_user_login_error>(new tbl_user_login_error()
                        {
                            user_id = singleuser.user_id, check_times = Convert.ToByte(reeoruser.check_times + 1), login_date = DateTime.Now, login_error_id = reeoruser.login_error_id
                        });
                    }
                    //记录登录日志
                    db.Insert <tbl_user_login_log>(insertlog(singleuser.emp_no, false));
                    result.State = 0;
                    result.Msg   = "密码错误";

                    return(result);
                }
                if (!usermodel.user_status)
                {
                    //记录登录日志
                    db.Insert <tbl_user_login_log>(insertlog(singleuser.emp_no, false));
                    result.State = 0;
                    result.Msg   = "该账号不可用,请联系管理员";

                    return(result);
                }
                //记录登录日志
                //用户登录成功清除登录错误次数
                if (reeoruser != null)
                {
                    db.Update <tbl_user_login_error>(new tbl_user_login_error()
                    {
                        user_id = singleuser.user_id, check_times = 0, login_date = DateTime.Now, login_error_id = reeoruser.login_error_id
                    });
                }
                db.Insert <tbl_user_login_log>(insertlog(singleuser.user_id, true));
                result.State      = 1;
                result.DataResult = usermodel;
                //将登入状态存入缓存
                SessionHelper.Add(CookieHelper.GetCookieValue("tockenid"), JsonHelper.SerializeObject(usermodel), SystemConfig.loginExpireTime);
                return(result);
            }
        }
Beispiel #30
0
        /// <summary>
        /// 从库登入
        /// </summary>
        /// <param name="user"></param>
        /// <param name="connectionStr">从库数据库链接字符串</param>
        /// <returns></returns>
        private ComResult CKlogin(base_users userModel, string connectionStr)
        {
            ComResult result = new ComResult();

            try
            {
                using (var db = SugarDao.GetInstance(connectionStr))
                {
                    //验证公司网点
                    var singlenet_no = db.Queryable <base_users>().SingleOrDefault(c => c.net_no == userModel.net_no && c.user_name == userModel.user_name);
                    if (singlenet_no == null)
                    {
                        result.State = 0;
                        result.Msg   = "公司网点与用户不匹配";

                        return(result);
                    }
                    //验证用户名和密码
                    var singleuser = db.Queryable <base_users>().SingleOrDefault(c => c.user_name == userModel.user_name);
                    if (singleuser == null)
                    {
                        result.State = 0;
                        result.Msg   = "用户不存在";

                        return(result);
                    }
                    //密码校验错误次数,超过5次设置10分钟的缓冲时间
                    //记录登录错误日志
                    var reeoruser = db.Queryable <base_login_error>().SingleOrDefault(c => c.user_id == singleuser.user_id);
                    if (reeoruser != null && reeoruser.check_times > 0 && reeoruser.check_times % 5 == 0 && DateTime.Now <= reeoruser.login_date.AddMinutes(10))
                    {
                        result.State = 0;
                        result.Msg   = "密码校验错误次数超过5次,请10分钟后尝试";
                        return(result);
                    }
                    var usermodel = db.Queryable <base_users>().SingleOrDefault(c => c.user_name == userModel.user_name && c.user_pwd == userModel.user_pwd);
                    if (usermodel == null)
                    {
                        if (reeoruser == null)
                        {
                            db.Insert <base_login_error>(new base_login_error()
                            {
                                user_id = singleuser.user_id, check_times = 1, login_date = DateTime.Now, create_time = DateTime.Now
                            });
                        }
                        else
                        {
                            db.Update <base_login_error>(new base_login_error()
                            {
                                user_id = singleuser.user_id, check_times = (byte)(reeoruser.check_times + 1), login_date = DateTime.Now, login_error_id = reeoruser.login_error_id, create_time = DateTime.Now
                            });
                        }
                        //记录登录日志
                        db.Insert <base_login_log>(Ckinsertlog(singleuser.user_id, false, singleuser.emp_id));
                        result.State = 0;
                        result.Msg   = "密码错误";

                        return(result);
                    }
                    if (!usermodel.user_status)
                    {
                        //记录登录日志
                        db.Insert <base_login_log>(Ckinsertlog(singleuser.user_id, false, singleuser.emp_id));
                        result.State = 0;
                        result.Msg   = "该账号不可用,请联系管理员";

                        return(result);
                    }
                    //记录登录日志
                    //用户登录成功清除登录错误次数
                    if (reeoruser != null)
                    {
                        db.Update <base_login_error>(new base_login_error()
                        {
                            user_id = singleuser.user_id, check_times = 0, login_date = DateTime.Now, login_error_id = reeoruser.login_error_id, create_time = DateTime.Now
                        });
                    }
                    db.Insert <base_login_log>(Ckinsertlog(singleuser.user_id, true, singleuser.emp_id));
                    result.State      = 1;
                    result.DataResult = usermodel;
                    //将登入状态存入缓存
                    SessionHelper.Add(CookieHelper.GetCookieValue("tockenid"), JsonHelper.SerializeObject(usermodel), SystemConfig.loginExpireTime);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.State = 0;
                result.Msg   = "系统异常" + ex.Message;
                return(result);

                throw;
            }
        }