コード例 #1
0
        /// <summary>
        /// 新增文章
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string AddNews(Mnews model, HttpPostedFileBase productimgurl = null, string path = "", int type = 1)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            string savePath = string.Empty;

            //// 存图片
            if (productimgurl != null)
            {
                string fileSave = FileOpert.UploadImg(productimgurl, path + "uploadFile\\" + System.DateTime.Now.ToString("yyyy") + "\\", out savePath);
                if (string.IsNullOrEmpty(fileSave))
                {
                    model.img = savePath.Replace(path, "");
                }
            }

            try
            {
                if (string.IsNullOrEmpty(model.id))
                {
                    DateTime dateTimeNow = System.DateTime.Now;
                    model.isDelete    = "0";
                    model.isEffective = "1";
                    model.great_time  = dateTimeNow;
                    model.modify_time = dateTimeNow;
                    model.type        = type;
                    model.id          = PublicTools.GetRandomNumberByTime();
                    if (new NewsService().AddNews(model))
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "操作成功!";
                    }
                    else
                    {
                        mwxResult.errmsg = "操作失败!";
                    }
                }
                else
                {
                    if (new NewsService().UpdateNews(model))
                    {
                        mwxResult.errcode = 0;
                        mwxResult.errmsg  = "操作成功!";
                    }
                    else
                    {
                        mwxResult.errmsg = "操作失败!";
                    }
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
コード例 #2
0
        /// <summary>
        /// 编辑产品
        /// </summary>
        /// <param name="mproduct"></param>
        /// <param name="productimgurl"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string EditeProduct(Mproduct mproduct, HttpPostedFileBase productimgurl, string path)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            if (productimgurl != null)
            {
                string savePath = string.Empty;
                string fileSave = FileOpert.UploadImg(productimgurl, path + "uploadFile\\" + System.DateTime.Now.ToString("yyyy") + "\\", out savePath);
                if (string.IsNullOrEmpty(fileSave))
                {
                    mproduct.productimgurl = savePath.Replace(path, "");
                }
            }

            bool addResult = new ProductService().UpdateProdctPrice(mproduct.productid,
                                                                    (decimal)mproduct.origprice, (decimal)mproduct.sellprice, (int)mproduct.stock, (int)mproduct.priority, mproduct);

            if (addResult)
            {
                mwxResult.errmsg              = "保存成功!";
                mwxResult.errcode             = 0;
                CacheData.allRecommendPro     = null;
                CacheData.allRecommendProList = null;
            }
            else
            {
                mwxResult.errmsg = "保存失败!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
コード例 #3
0
        /// <summary>
        /// 新增产品
        /// </summary>
        /// <param name="mproduct"></param>
        /// <param name="productimgurl"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string AddProduct(Mproduct mproduct, HttpPostedFileBase productimgurl, string path)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            //// 实现步骤
            //// 1.数据合法性验证
            //// 2.图片入库
            //// 3.数据落地
            string savePath = string.Empty;

            mwxResult.errmsg = this.CheckedProduct(mproduct);

            if (productimgurl == null)
            {
                mwxResult.errmsg = "产品图片不能为空!";
                return(JsonHelper.GetJson <MwxResult>(mwxResult));
            }

            if (!string.IsNullOrEmpty(mwxResult.errmsg))
            {
                return(JsonHelper.GetJson <MwxResult>(mwxResult));
            }

            //// 存图片
            string fileSave = FileOpert.UploadImg(productimgurl, path + "uploadFile\\" + System.DateTime.Now.ToString("yyyy") + "\\", out savePath);

            if (string.IsNullOrEmpty(fileSave))
            {
                mproduct.productimgurl = savePath.Replace(path, "");
            }
            else
            {
                //// 构建错误信息并返回
                mwxResult.errmsg = fileSave;
                return(JsonHelper.GetJson <MwxResult>(mwxResult));
            }

            mproduct.productid = PublicTools.GetRandomNumberByTime();
            ///// 入库
            bool addResult = new ProductService().AddProduct(mproduct);

            if (addResult)
            {
                mwxResult.errmsg              = "新增成功!";
                mwxResult.errcode             = 0;
                CacheData.allRecommendPro     = null;
                CacheData.allRecommendProList = null;
            }
            else
            {
                mwxResult.errmsg = "新增失败!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
コード例 #4
0
        public void Delete()
        {
            string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + m_strStepName;

            if (Directory.Exists(strPath))
            {
                FileOpert.DeleteFolder(strPath);
            }
        }
        /// <summary>
        /// 下载团购费信息
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="buildNum"></param>
        public string DownLoadTFCInforMeth(string userName, string buildNum, string amountType)
        {
            string url      = "Downloads/TFCTuanGouF" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            string excelUrl = Server.MapPath("~/" + url);

            FileOpert.CreateFile(url);
            new TFCEvidenceInforBus().DownLoadTFCInfor(excelUrl, userName, buildNum, amountType);
            return(url);
        }
コード例 #6
0
        /// <summary>
        /// 编辑产品类别
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string EditProductclass(Mproductclass model, HttpPostedFileBase productimgurl, string path)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                //// 数据合法性检查
                if (model == null || model.classid < 1 || string.IsNullOrEmpty(model.classname))
                {
                    mwxResult.errmsg = "操作失败,新增数据不能为空!";
                }

                if (productimgurl != null)
                {
                    string savePath = string.Empty;
                    string fileSave = FileOpert.UploadImg(productimgurl, path + "uploadFile\\" + System.DateTime.Now.ToString("yyyy") + "\\", out savePath);
                    if (string.IsNullOrEmpty(fileSave))
                    {
                        model.imgpath = savePath.Replace(path, "");
                    }
                }

                //// 数据落地入库
                if (!new ProductclassService().EditProductclass(model))
                {
                    mwxResult.errmsg = "操作失败";
                }
                else
                {
                    mwxResult.errcode         = 0;
                    mwxResult.errmsg          = "操作成功";
                    CacheData.allProductClass = null;
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }
コード例 #7
0
        //public static void DeleteFolder(string dirPath)
        //{
        //    if (Directory.Exists(dirPath))
        //    {
        //        foreach (string content in Directory.GetFileSystemEntries(dirPath))
        //        {
        //            if (Directory.Exists(content))
        //            { Directory.Delete(content, true); }
        //            else if (File.Exists(content))
        //            { File.Delete(content); }
        //        }
        //    }
        //}

        private void BtnDel_Click(object sender, EventArgs e)
        {
            if (treeView_ProdutFile.SelectedNode == null)
            {
                MessageBox.Show("请选择要添加子节点的节点!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (treeView_ProdutFile.SelectedNode == treeView_ProdutFile.Nodes[0])
            {
                MessageBox.Show("不能删除根结点!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (ParamSetMgr.GetInstance().CurrentWorkDir == "")
            {
                MessageBox.Show("当前产品目录文件夹!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            bool bFind = Directory.Exists(ParamSetMgr.GetInstance().CurrentWorkDir);

            if (!bFind)
            {
                MessageBox.Show("当前产品目录文件夹!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (treeView_ProdutFile.SelectedNode == treeView_ProdutFile.Nodes[0].Nodes[0])
            {
                MessageBox.Show("当前产品文件不能删除,请先载入!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string strdirPath = ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + treeView_ProdutFile.SelectedNode.Text;

            if (MessageBox.Show($"是否确定删除{treeView_ProdutFile.SelectedNode.Text}", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
            {
                return;
            }
            if (Directory.Exists(strdirPath))
            {
                // DeleteFolder(strdirPath);
                FileOpert.DeleteFolder(strdirPath);
            }
            treeView_ProdutFile.SelectedNode.Remove();
        }
コード例 #8
0
        /// <summary>
        /// 新增产品类别
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string AddProductclasses(Mproductclass model, HttpPostedFileBase productimgurl, string path)
        {
            MwxResult mwxResult = new MwxResult()
            {
                errcode = -1
            };

            try
            {
                //// 数据合法性检查
                if (model == null || string.IsNullOrEmpty(model.classname))
                {
                    mwxResult.errmsg = "操作失败,新增数据不能为空!";
                }

                if (productimgurl == null)
                {
                    mwxResult.errmsg = "图片不能为空!";
                    return(JsonHelper.GetJson <MwxResult>(mwxResult));
                }

                string savePath = string.Empty;

                //// 存图片
                string fileSave = FileOpert.UploadImg(productimgurl, path + "uploadFile\\" + System.DateTime.Now.ToString("yyyy") + "\\", out savePath);
                if (string.IsNullOrEmpty(fileSave))
                {
                    model.imgpath = savePath.Replace(path, "");
                }
                else
                {
                    //// 构建错误信息并返回
                    mwxResult.errmsg = fileSave;
                    return(JsonHelper.GetJson <MwxResult>(mwxResult));
                }

                //// 时间相关参数赋值
                model.great_time  = System.DateTime.Now;
                model.modify_time = model.great_time;
                model.isDelete    = 0;
                model.isEffective = 1;

                //// 数据落地入库
                if (!new ProductclassService().AddProductclass(model))
                {
                    mwxResult.errmsg = "操作失败";
                }
                else
                {
                    mwxResult.errcode         = 0;
                    mwxResult.errmsg          = "操作成功";
                    CacheData.allProductClass = null;
                }
            }
            catch (Exception ex)
            {
                mwxResult.errmsg = "操作失败:系统异常!";
            }

            return(JsonHelper.GetJson <MwxResult>(mwxResult));
        }