Beispiel #1
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        //验证码
        //if (Request["txtYZM"] == null || Session["VerifyChar"] == null) { return; }
        //if (Session["VerifyChar"].ToString().ToLower() != Request["txtYZM"].ToString().ToLower())
        //{
        //    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<Script>alert('验证码错误!');</Script>");
        //    return;
        //}
        string username = this.txtUsername.Value.Trim().Replace("'", "");
        string pwd      = this.txtPassword.Value;

        pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5");
        //Response.Write(pwd); Response.End();
        DataTable dtUser = new DataTable();
        int       r      = new StarTech.Adapter.IACenter().UserLogin(username, pwd, ref dtUser);

        if (r == 1)
        {
            //日志
            //iacenter.AddUserActionLog(dt.Rows[0]["UserName"].ToString(), dt.Rows[0]["TrueName"].ToString(), "", "", "", "登陆", "", "", "", Request.UserHostAddress, Request.Url.ToString());

            Session["UserId"] = dtUser.Rows[0]["uniqueId"].ToString();
            LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "用户‘" + dtUser.Rows[0]["userName"].ToString() + "’登录", "登录", "", "", HttpContext.Current.Request.Url.ToString());

            //string ids = GetRootMenus(dt.Rows[0]["uniqueId"].ToString());
            string ids = "1";
            if (ids != "")
            {
                Response.Redirect("Main.aspx?rootMenuId=" + ids.Split(',')[0] + "", true);
            }
            else
            {
                Response.Redirect("Main.aspx?rootMenuId=-1", true);
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户名或密码错误!');</script>");
        }
    }
Beispiel #2
0
    //删除
    void Delete1_DeleteClickEvent(object sender, EventArgs e)
    {
        ArrayList selectedNodes = TreeNodeUtil.GetSelectedTreeNodes(this.treeMenu.Nodes[0]);

        if (selectedNodes.Count == 0)
        {
            JSUtility.Alert("请选择要删除的页节点!");
        }
        else
        {
            int[]  selectedIds = new int[selectedNodes.Count];
            string typeList    = "";
            for (int i = 0; i < selectedNodes.Count; i++)
            {
                selectedIds[i] = Convert.ToInt32(((TreeNode)selectedNodes[i]).Value);
                typeList      += "《" + ((TreeNode)selectedNodes[i]).Text + "》";

                /*日志归档*/
                //  string sql = @"select l.Description as title from T_Permission l where PermissionId=" + selectedIds[i].ToString() + "";
                //  PubFunction.InsertLog("系统管理", "菜单管理", "菜单列表", "删除", sql, selectedIds[i].ToString());
            }
            bool sucess = this.bll.Delete(selectedIds);
            if (sucess)
            {
                LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "删除菜谱分类" + typeList + "", "删除", "", "", HttpContext.Current.Request.Url.ToString());

                JSUtility.Alert("删除菜单项成功!");
            }
            else
            {
                JSUtility.Alert("包含子节点的菜单项无法删除,子节点已删除!");
            }
            this.treeMenu.Nodes.Clear();
            //this.treeMenu.Nodes.Add(this._menu.GetMenuTree(false));
            BindTreeView();
        }
    }
Beispiel #3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int updateInt = -1;

        if (this.id == "")
        {
            if (this.FileUpload1.HasFile == false)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('请选择任务图片');</script>");
                return;
            }


            GoodsModel mod = new GoodsModel();
            mod.GoodsId = IdCreator.CreateId("T_Goods_Info", "GoodsId");
            mod.AddTime = DateTime.Now;

            if (hfSign.Value.Length > 0)
            {
                mod.signId = hfSign.Value;
            }
            else
            {
                mod.signId = "";
            }
            string fileExt = System.IO.Path.GetExtension(this.FileUpload1.FileName).ToLower();



            if (fileExt != ".jpeg" && fileExt != ".jpg" && fileExt != ".png" && fileExt != ".bmp" && fileExt != ".gif")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('图片格式不正确');</script>");
                return;
            }
            if (this.FileUpload1.PostedFile.ContentLength > 1024000)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('图片不能大于1M');</script>");
                return;
            }
            string newFileName = Guid.NewGuid().ToString() + fileExt;
            string dir         = "/upload/goodsadmin/" + DateTime.Now.ToString("yyyyMMdd") + "/";
            if (System.IO.Directory.Exists(Server.MapPath(dir)) == false)
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(dir));
            }
            string newPath = dir + newFileName;


            this.FileUpload1.SaveAs(Server.MapPath(newPath));
            //缩略图
            MakeSmallPic(Server.MapPath(newPath), Server.MapPath(newPath.Replace(fileExt, "_s" + fileExt)));
            mod.GoodsSmallPic = newPath.Replace(fileExt, "_s" + fileExt);
            //mod.GoodsSmallPic = newPath.Replace(fileExt, "" + fileExt);
            ViewState["OriginalBigImg"] = mod.GoodsSmallPic;
            GetFormInfo(ref mod);
            if (mod.CategoryId == "1")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('未选择分类')</script>");
            }
            if (bll.Add(mod) > 0)
            {
                string strShop = "select shopId from T_Shop_User where isdefault=1;";

                DataSet ds = StarTech.DBUtility.AdoHelper.CreateHelper(AppConfig.DBInstance).ExecuteSqlDataset(strShop);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        string   newGuid   = Guid.NewGuid().ToString();
                        string   shopId    = ds.Tables[0].Rows[0][0].ToString();
                        string   goodsId   = mod.GoodsId;
                        int      num       = mod.Sotck.Value;
                        decimal  price     = mod.SalePrice.Value;
                        int      isSell    = mod.IsSale.Value;
                        DateTime addt      = DateTime.Now;
                        string   goodsCode = mod.GoodsCode;
                        string   strGoods  = "insert into T_Shop_Goods values('" + newGuid + "','" + shopId + "','" + goodsId + "'," + num + "," + price + "," + isSell + ",'" + addt + "','" + goodsCode + "',0,0,0,0);";
                        StarTech.DBUtility.AdoHelper.CreateHelper(AppConfig.DBInstance).ExecuteSqlNonQuery(strGoods);
                    }
                }
                string         strItem = "insert T_Menu_Item(itemName,itemImgSrc,ifBuy,GoodsId,orderBy,remark,unit) values(@itemName,@itemImgSrc,@ifBuy,@GoodsId,@orderBy,@remark,@unit);";
                SqlParameter[] q       =
                {
                    //  @itemImgSrc,@ifBuy,@GoodsId,@orderBy,@remark,@unit
                    new SqlParameter("@itemName",   SqlDbType.VarChar),
                    new SqlParameter("@itemImgSrc", SqlDbType.VarChar),
                    new SqlParameter("@ifBuy",      SqlDbType.Int),
                    new SqlParameter("@GoodsId",    SqlDbType.VarChar),
                    new SqlParameter("@orderBy",    SqlDbType.Int),
                    new SqlParameter("@remark",     SqlDbType.VarChar),
                    new SqlParameter("@unit",       SqlDbType.VarChar)
                };
                q[0].Value = mod.GoodsName;
                q[1].Value = mod.GoodsSmallPic;
                q[2].Value = 1;
                q[3].Value = mod.GoodsId;
                q[4].Value = 9999;
                q[5].Value = "任务“" + mod.GoodsName + "”添加";
                q[6].Value = mod.Uint;

                int rows = StarTech.DBUtility.AdoHelper.CreateHelper(AppConfig.DBInstance).ExecuteSqlNonQuery(strItem, q);

                //默认幻灯图片
                //if (ViewState["OriginalBigImg"] != null) { AddDefaultPic(mod.GoodsId, ViewState["OriginalBigImg"].ToString()); }
                LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "添加课程《" + mod.GoodsName + "》", "添加", "", "", HttpContext.Current.Request.Url.ToString());

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>if(confirm('保存成功')){location.href='GoodsAdd.aspx?id=" + mod.GoodsId + "'}else{}</script>");
            }
        }
        else
        {
            updateInt = 0;
            //string strSQL = "select * from T_Goods_Update where goodsid='" + id+"' and updatetime>'"+DateTime.Now.ToShortDateString()+" 00:00:00';";
            string    strSQL    = "";
            AdoHelper adohelper = StarTech.DBUtility.AdoHelper.CreateHelper(AppConfig.DBInstance);
            //DataSet ds = adohelper.ExecuteSqlDataset(strSQL);

            //if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count >= 0)
            //{
            //    if (ds.Tables[0].Rows.Count > 2)
            //    {
            //        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('编辑成功');</script>");
            //        return;
            //    }
            //    else
            //    {
            //        updateInt = 2 - ds.Tables[0].Rows.Count;
            //    }
            //}



            GoodsModel mod = bll.GetModel(this.id);
            if (this.FileUpload1.HasFile == true)
            {
                string fileExt = System.IO.Path.GetExtension(this.FileUpload1.FileName).ToLower();
                if (fileExt != ".jpeg" && fileExt != ".jpg" && fileExt != ".png" && fileExt != ".bmp" && fileExt != ".gif")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('图片格式不正确');</script>");
                    return;
                }
                if (this.FileUpload1.PostedFile.ContentLength > 10240000)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('图片不能大于10M');</script>");
                    return;
                }
                string newFileName = Guid.NewGuid().ToString() + fileExt;
                string dir         = "/upload/goodsadmin/" + DateTime.Now.ToString("yyyyMMdd") + "/";
                if (System.IO.Directory.Exists(Server.MapPath(dir)) == false)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(dir));
                }
                string newPath = dir + newFileName;

                this.FileUpload1.SaveAs(Server.MapPath(newPath));
                //缩略图
                MakeSmallPic(Server.MapPath(newPath), Server.MapPath(newPath.Replace(fileExt, "_s" + fileExt)));
                mod.GoodsSmallPic = newPath.Replace(fileExt, "_s" + fileExt);
                //mod.GoodsSmallPic = newPath.Replace(fileExt, "" + fileExt);
                ViewState["OriginalBigImg"] = mod.GoodsSmallPic;
            }
            //hfSign.Value = hfSign.Value.Replace("--", "-");
            if (hfSign.Value.Length > 0)
            {
                mod.signId = hfSign.Value;
            }
            else
            {
                mod.signId = "";
            }



            GetFormInfo(ref mod);
            if (bll.Update(mod))
            {
                adohelper.ExecuteSqlNonQuery("update T_Goods_Info set JobDay=datediff(day,JobStartTime,JobEndTime) where GoodsId='" + mod.GoodsId + "'");

                //默认图片
                //if (ViewState["OriginalBigImg"] != null) { AddDefaultPic(mod.GoodsId, ViewState["OriginalBigImg"].ToString()); }
                //if (updateInt == -1)
                //    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存成功');location.href='GoodsList.aspx?id=" + this.cselect.categoryID + "';</script>");
                //else{
                strSQL = "insert T_Goods_Update values('" + mod.GoodsId + "',getdate(),'');";
                adohelper.ExecuteSqlNonQuery(strSQL);
                LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "编辑任务《" + mod.GoodsName + "》", "编辑", "", "", HttpContext.Current.Request.Url.ToString());

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('编辑成功');</script>");
                //}
            }
        }
    }
Beispiel #4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string serviceName    = KillSqlIn.Form_ReplaceByString(txtName.Text, 50);
        string serviceContext = KillSqlIn.Form_ReplaceByString(txtContext.Text, 50);
        int    orderBy        = 0;

        int.TryParse(txtOrder.Text, out orderBy);
        string remark = KillSqlIn.Form_ReplaceByString(txtRemark.Text, 50);

        string [] valueList   = txtValue.Text.Split(',');
        string[]  priceList   = txtPrice.Text.Split(',');
        string[]  defaultList = txtDefault.Text.Split(',');
        string    strSQL      = "";


        if (serviceId == "")
        {
            var guid = Guid.NewGuid().ToString();
            if (valueList.Length != priceList.Length || valueList.Length != defaultList.Length)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('服务选项,价格以及默认值存在不匹配');</script>");
                return;
            }
            strSQL  = " BEGIN TRANSACTION  ";
            strSQL += "insert T_Goods_Service values('" + guid + "','" + serviceName + "','" + serviceContext + "'," + orderBy + ",'" + remark + "');";
            for (int i = 0; i < valueList.Length; i++)
            {
                //txtName.Text = ds.Tables[0].Rows[0]["serviceName"].ToString();
                //txtName.Text = ds.Tables[0].Rows[0]["serviceName"].ToString();
                string  value = KillSqlIn.Form_ReplaceByString(valueList[i], 50);
                decimal d     = 0;
                decimal.TryParse(priceList[i], out d);
                int dd = 0;
                int.TryParse(defaultList[i], out dd);
                strSQL += "insert T_Goods_ServiceDetail values('" + guid + i + "','" + guid + "','" + value + "','" + d + "',''," + dd + ");";
            }

            strSQL += " COMMIT TRANSACTION ";
            int rows = adoHelper.ExecuteSqlNonQuery(strSQL);
            if (rows > 0)
            {
                LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "添加任务服务《" + serviceName + "》", "添加", "", "", HttpContext.Current.Request.Url.ToString());

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('添加成功');</script>");
            }
        }
        else
        {
            if (valueList.Length != priceList.Length || valueList.Length != defaultList.Length)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('服务选项,价格以及默认值不匹配');</script>");
                return;
            }
            strSQL  = " BEGIN TRANSACTION  ";
            strSQL += "update  T_Goods_Service set serviceName='" + serviceName + "',serviceContext='" + serviceContext + "',orderBy=" + orderBy + ",remark='" + remark + "' where serviceId='" + serviceId + "';";
            for (int i = 0; i < valueList.Length; i++)
            {
                //txtName.Text = ds.Tables[0].Rows[0]["serviceName"].ToString();
                //txtName.Text = ds.Tables[0].Rows[0]["serviceName"].ToString();
                string  value = KillSqlIn.Form_ReplaceByString(valueList[i], 50);
                decimal d     = 0;
                decimal.TryParse(priceList[i], out d);
                int dd = 0;
                int.TryParse(defaultList[i], out dd);
                //strSQL += "insert T_Goods_ServiceDetail values('" + guid + i + "','" + guid + "','" + value + "','" + d + "',''," + dd + ");";
                if (ds.Tables[1].Rows.Count > i)
                {
                    strSQL += "update T_Goods_ServiceDetail set value='" + value + "',price=" + d + ",isDefault=" + dd + " where sysnumber='" + ds.Tables[1].Rows[i]["sysnumber"] + "';";
                }
                else
                {
                    strSQL += "insert T_Goods_ServiceDetail values('" + ds.Tables[0].Rows[0]["serviceId"] + i + "','" + ds.Tables[0].Rows[0]["serviceId"] + "','" + value + "','" + d + "',''," + dd + ");";
                }
            }
            strSQL += " COMMIT TRANSACTION ";

            int rows = adoHelper.ExecuteSqlNonQuery(strSQL);

            if (rows > 0)
            {
                LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "修改任务服务《" + serviceName + "》", "添加", "", "", HttpContext.Current.Request.Url.ToString());

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('修改成功');</script>");
            }
        }
    }
Beispiel #5
0
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        GoodsTypeModel mod;

        if (this.id != "" && this.id != null)
        {
            mod = bll.GetModel(this.id);
        }
        else
        {
            mod = new GoodsTypeModel();
        }
        string pPath = "";

        string[] codeList = this.cSelect.hfCode.Split('|');
        StarTech.DBUtility.AdoHelper adoHelper = StarTech.DBUtility.AdoHelper.CreateHelper("DB_Instance");



        if (codeList.Length < 1 || cSelect.hfCode == "")
        {
            mod.PCategoryId   = "";
            mod.CategoryLevel = 1;
            mod.CategoryPath  = mod.CategoryId;
        }
        else
        {
            //if(this.cSelect.categoryID)
            mod.PCategoryId = codeList[codeList.Length - 1];

            DataSet ds = adoHelper.ExecuteSqlDataset("select * from T_Info_Category where categoryid='" + KillSqlIn.Form_ReplaceByString(mod.PCategoryId, 20) + "';");
            mod.CategoryLevel = Convert.ToInt32(ds.Tables[0].Rows[0]["CategoryLevel"].ToString()) + 1;
            pPath             = ds.Tables[0].Rows[0]["CategoryPath"].ToString();
        }

        if (pPath != "")
        {
            pPath += ",";
        }

        mod.CategoryName = this.txtMenuName.Text.Trim();
        //mod.CategoryPath=
        //mod.Remarks = this.txtRemarks.Text.Trim();
        int orderdy = 0;

        int.TryParse(this.txtSort.Text.Trim(), out orderdy);
        mod.Orderby      = orderdy;
        mod.CategoryFlag = (this.cbIsVisible.Checked == true) ? "Course" : "Category";

        if (fuImg.FileName != null && fuImg.FileName != "")
        {
            //mod.Url = fuImg.FileName;
            string nowUrl = Guid.NewGuid().ToString();
            string tzm    = fuImg.FileName.Substring(fuImg.FileName.LastIndexOf("."));
            string url    = "/upload/Category/" + nowUrl + "" + tzm;
            fuImg.SaveAs(Server.MapPath("~" + url));
            mod.Url = url;
        }

        if (this.id != "" && this.id != null)
        {
            if (this.id == mod.PCategoryId)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('上级分类不能选择当前分类');layer_close_refresh();</script>");
                return;
            }
            mod.CategoryPath = pPath + mod.CategoryId;
            if (bll.Update(mod))
            {
                LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "修改任务分类《" + mod.CategoryName + "》", "修改", "", "", HttpContext.Current.Request.Url.ToString());
                ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");
            }
        }
        else
        {
            mod.CategoryId = IdCreator.CreateId("T_Info_Category", "CategoryId");

            mod.CategoryPath = pPath + mod.CategoryId;
            bll.Add(mod);
            LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "添加任务分类《" + mod.CategoryName + "》;", "添加", "", "", HttpContext.Current.Request.Url.ToString());
            ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('添加成功');layer_close_refresh();</script>");
            //JSUtility.ReplaceOpenerParentWindow("menuTree.aspx");
        }

        //ModMenu detail = new ModMenu();
        //detail.menuName = this.txtMenuName.Text.Trim();
        //detail.menuTarget = this.txtMenuLink.Text.Trim();
        //detail.isShow = (this.cbIsVisible.Checked == true ? 1 : 0);
        //detail.orderIndex = Convert.ToInt32(this.txtSort.Text.Trim());
        //detail.parentMenuId = Convert.ToInt32(this.cSelect.categoryID);
        //if (this._menuId != null)
        //{
        //    int menuId = Convert.ToInt32(this._menuId);
        //    detail.uniqueId = menuId;
        //    this._menu.Update(detail);
        //    ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");
        //}
        //else
        //{
        //    this._menu.Add(detail);
        //    ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('添加成功');layer_close_refresh();</script>");
        //    //JSUtility.ReplaceOpenerParentWindow("menuTree.aspx");
        //}
    }
Beispiel #6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int updateInt = -1;

        if (this.id == "")
        {
            if (this.FileUpload1.HasFile == false)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('请选择任务图片');</script>");
                return;
            }

            if (this.ddlMorePropertys.SelectedValue == "视频和练习")
            {
                if (this.FileUpload2.HasFile == false)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('请选择视频文件');</script>");
                    return;
                }
            }

            GoodsModel mod = new GoodsModel();
            mod.GoodsId    = IdCreator.CreateId("T_Goods_Info", "GoodsId");
            mod.AddTime    = DateTime.Now;
            mod.CategoryId = mod.GoodsToTypeId = this.hid_pgoodsid.Value;
            if (hfSign.Value.Length > 0)
            {
                mod.signId = hfSign.Value;
            }
            else
            {
                mod.signId = "";
            }


            string fileExt = System.IO.Path.GetExtension(this.FileUpload1.FileName).ToLower();
            if (fileExt != ".jpeg" && fileExt != ".jpg" && fileExt != ".png" && fileExt != ".bmp" && fileExt != ".gif")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('图片格式不正确');</script>");
                return;
            }
            if (this.FileUpload1.PostedFile.ContentLength > 1024000)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('图片不能大于1M');</script>");
                return;
            }
            string newFileName = Guid.NewGuid().ToString() + fileExt;
            string dir         = "/upload/goodsadmin/" + DateTime.Now.ToString("yyyyMMdd") + "/";
            if (System.IO.Directory.Exists(Server.MapPath(dir)) == false)
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(dir));
            }
            string newPath = dir + newFileName;


            this.FileUpload1.SaveAs(Server.MapPath(newPath));
            //缩略图
            //MakeSmallPic(Server.MapPath(newPath), Server.MapPath(newPath.Replace(fileExt, "_s" + fileExt)));
            //mod.GoodsSmallPic = newPath.Replace(fileExt, "_s" + fileExt);
            mod.GoodsSmallPic           = newPath;
            ViewState["OriginalBigImg"] = mod.GoodsSmallPic;


            //视频文件_start
            if (this.FileUpload2.HasFile == true)
            {
                string fileExt_video = System.IO.Path.GetExtension(this.FileUpload2.FileName).ToLower();
                if (fileExt_video != ".mp4")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('视频格式不正确');</script>");
                    return;
                }
                string newFileName_video = Guid.NewGuid().ToString() + fileExt_video;
                string dir_video         = "/upload/goodsadmin/" + DateTime.Now.ToString("yyyyMMdd") + "/";
                if (System.IO.Directory.Exists(Server.MapPath(dir_video)) == false)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(dir_video));
                }
                string newPath_video = dir_video + newFileName_video;
                this.FileUpload2.SaveAs(Server.MapPath(newPath_video));
                mod.BookInfo = newPath_video;
            }
            //视频文件_end

            GetFormInfo(ref mod);
            if (mod.CategoryId == "1")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('未选择分类')</script>");
            }
            if (bll.Add(mod) > 0)
            {
                //默认幻灯图片
                //if (ViewState["OriginalBigImg"] != null) { AddDefaultPic(mod.GoodsId, ViewState["OriginalBigImg"].ToString()); }
                LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "添加任务《" + mod.GoodsName + "》", "添加", "", "", HttpContext.Current.Request.Url.ToString());

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>if(confirm('保存成功')){location.href='SubGoodsAdd.aspx?id=" + mod.GoodsId + "'}else{}</script>");
            }
        }
        else
        {
            updateInt = 0;
            //string strSQL = "select * from T_Goods_Update where goodsid='" + id+"' and updatetime>'"+DateTime.Now.ToShortDateString()+" 00:00:00';";
            string    strSQL    = "";
            AdoHelper adohelper = StarTech.DBUtility.AdoHelper.CreateHelper(AppConfig.DBInstance);
            //DataSet ds = adohelper.ExecuteSqlDataset(strSQL);

            //if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count >= 0)
            //{
            //    if (ds.Tables[0].Rows.Count > 2)
            //    {
            //        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('编辑成功');</script>");
            //        return;
            //    }
            //    else
            //    {
            //        updateInt = 2 - ds.Tables[0].Rows.Count;
            //    }
            //}



            GoodsModel mod = bll.GetModel(this.id);
            if (this.FileUpload1.HasFile == true)
            {
                string fileExt = System.IO.Path.GetExtension(this.FileUpload1.FileName).ToLower();
                if (fileExt != ".jpeg" && fileExt != ".jpg" && fileExt != ".png" && fileExt != ".bmp" && fileExt != ".gif")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('图片格式不正确');</script>");
                    return;
                }
                if (this.FileUpload1.PostedFile.ContentLength > 1024000)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('图片不能大于1M');</script>");
                    return;
                }
                string newFileName = Guid.NewGuid().ToString() + fileExt;
                string dir         = "/upload/goodsadmin/" + DateTime.Now.ToString("yyyyMMdd") + "/";
                if (System.IO.Directory.Exists(Server.MapPath(dir)) == false)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(dir));
                }
                string newPath = dir + newFileName;

                this.FileUpload1.SaveAs(Server.MapPath(newPath));
                //缩略图
                //MakeSmallPic(Server.MapPath(newPath), Server.MapPath(newPath.Replace(fileExt, "_s" + fileExt)));
                //mod.GoodsSmallPic = newPath.Replace(fileExt, "_s" + fileExt);
                mod.GoodsSmallPic           = newPath;
                ViewState["OriginalBigImg"] = mod.GoodsSmallPic;
            }


            //视频文件_start
            if (this.FileUpload2.HasFile == true)
            {
                string fileExt_video = System.IO.Path.GetExtension(this.FileUpload2.FileName).ToLower();
                if (fileExt_video != ".mp4")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('视频格式不正确');</script>");
                    return;
                }
                string newFileName_video = Guid.NewGuid().ToString() + fileExt_video;
                string dir_video         = "/upload/goodsadmin/" + DateTime.Now.ToString("yyyyMMdd") + "/";
                if (System.IO.Directory.Exists(Server.MapPath(dir_video)) == false)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(dir_video));
                }
                string newPath_video = dir_video + newFileName_video;
                this.FileUpload2.SaveAs(Server.MapPath(newPath_video));
                mod.BookInfo = newPath_video;
            }
            //视频文件_end

            //hfSign.Value = hfSign.Value.Replace("--", "-");
            if (hfSign.Value.Length > 0)
            {
                mod.signId = hfSign.Value;
            }
            else
            {
                mod.signId = "";
            }



            GetFormInfo(ref mod);
            if (bll.Update(mod))
            {
                adohelper.ExecuteSqlNonQuery("update T_Goods_Info set JobDay=datediff(day,JobStartTime,JobEndTime) where GoodsId='" + mod.GoodsId + "'");

                //默认图片
                //if (ViewState["OriginalBigImg"] != null) { AddDefaultPic(mod.GoodsId, ViewState["OriginalBigImg"].ToString()); }
                //if (updateInt == -1)
                //    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存成功');location.href='GoodsList.aspx?id=" + this.cselect.categoryID + "';</script>");
                //else{
                strSQL = "insert T_Goods_Update values('" + mod.GoodsId + "',getdate(),'');";
                adohelper.ExecuteSqlNonQuery(strSQL);
                LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "编辑任务《" + mod.GoodsName + "》", "编辑", "", "", HttpContext.Current.Request.Url.ToString());

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('编辑成功');</script>");
                //}
            }
        }
    }
Beispiel #7
0
    /// <summary>
    /// 保存信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        MenuModel model = new MenuModel();

        if (menuId != null && menuId != "")
        {
            model = new MenuBll().GetModel(menuId);
            if (model == null)
            {
                model = new MenuModel();
            }
        }
        model.menuName = txtMenuName.Text;
        model.Flavor   = txtFlavor.Text;
        //model.Technology=ddlTechnology.SelectedValue;
        model.Technology   = txtTechnology.Text;
        model.Flavor       = txtFlavor.Text;
        model.CookingTime  = txtCookieTime.Text;
        model.CookingSkill = txtCookingSkill.Text;
        string[] strCode = selectMenu.hfCode.Split('|');
        if (strCode.Length > 0)
        {
            model.categoryId = strCode[strCode.Length - 1];
        }
        if (strCode[strCode.Length - 1] == "")
        {
            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('未选择分类');</script>");
        }
        if (hfSign.Value.Length > 0)
        {
            model.signId = hfSign.Value;
        }
        else
        {
            model.signId = "";
        }

        decimal d = 0;

        if (decimal.TryParse(txtCalorie.Text, out d))
        {
            model.Calorie = d;
        }
        model.isShow = cbShow.Checked ? 1 : 0;
        model.isTop  = cbTop.Checked ? 1 : 0;

        if (fuBigImg.FileName.ToLower().Contains(".jpg") || fuBigImg.FileName.ToLower().Contains(".png") || fuBigImg.FileName.ToLower().Contains(".bmp") || fuBigImg.FileName.ToLower().Contains(".gif"))
        {
            string filePath = "/Upload/Menu/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/";
            if (!Directory.Exists(Server.MapPath(filePath)))
            {
                Directory.CreateDirectory(Server.MapPath(filePath));
            }
            string fileName = DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second + new Random().Next(10, 99);
            string tzm      = fuBigImg.FileName.Substring(fuBigImg.FileName.LastIndexOf("."));
            fuBigImg.SaveAs(Server.MapPath(filePath + fileName + tzm));
            model.imgSrc = filePath + fileName + tzm;
            if (model.imgSrc != null && model.imgSrc != "")
            {
                llBigImg.Text = "<img src='" + model.imgSrc + "' width='100px' height='100px'/>";
            }
        }
        else if (fuBigImg.FileName != null && fuBigImg.FileName != "")
        {
            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('展示图图片格式不正确');</script>");
            return;
        }

        if (fuSmallImg.FileName.ToLower().Contains(".jpg") || fuSmallImg.FileName.ToLower().Contains(".png") || fuSmallImg.FileName.ToLower().Contains(".bmp") || fuSmallImg.FileName.ToLower().Contains(".gif"))
        {
            string filePath = "/Upload/Menu/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/";
            string fileName = DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second + new Random().Next(10, 99);
            string tzm      = fuSmallImg.FileName.Substring(fuSmallImg.FileName.LastIndexOf("."));
            fuSmallImg.SaveAs(Server.MapPath(filePath + fileName + tzm));
            model.smallImgSrc = filePath + fileName + tzm;
            if (model.smallImgSrc != null && model.smallImgSrc != "")
            {
                llSmallImg.Text = "<img src='" + model.smallImgSrc + "' width='100px' height='100px'/>";
            }
        }
        else if (fuSmallImg.FileName != null && fuSmallImg.FileName != "")
        {
            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('预览图图片格式不正确');</script>");
            return;
        }

        if (menuId == null || menuId == "")
        {
            model.menuId  = IdCreator.CreateId("T_Menu_Info", "menuId");
            model.AddTime = DateTime.Now;
            if (new MenuBll().Add(model))
            {
                BindItemInfo(model.menuId);
                LogAdd.CreateLog(Session["UserId"].ToString(), "添加菜谱《" + model.menuName + "》", "添加", "", "", Request.Url.ToString());
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('添加成功');layer_close_refresh();</script>");
            }
        }
        else
        {
            //model.menuId = IdCreator.CreateId("T_Menu_Info", "menuId");
            if (new MenuBll().Update(model))
            {
                BindItemInfo(model.menuId);
                LogAdd.CreateLog(Session["UserId"].ToString(), "修改菜谱《" + model.menuName + "》", "修改", "", "", Request.Url.ToString());
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('修改成功');layer_close_refresh();</script>");
            }
        }
    }