Esempio n. 1
0
        private void Of_bind_Goods()
        {
            int li_PageIndex = 1;

            try { li_PageIndex = Convert.ToInt32(Lbl_PageIndex.Text); }
            catch { }

            string ls_SQL = @"select isnull((select ThumbnaiIimg from Goodsno_picture where Goo_code=goodsno.goo_code),'img/error.png')as ThumbnaiIimg,
                            goodsno.goo_code,goodsno.goo_no,goodsno.specnum,goodsno.Goo_Type,goodsno.Goo_Mate,goodsno.goo_name,0.00 as UserPrice,goodsno.Spec,
                            goodsno.Content,goodsno.Goo_unit,goodsno.getdetail_memo,0 as num,0 as piece
                            from goodsno,goodmate,goodtype where 1=1 
                            and goo_type=typeno and goo_mate*=matecode and goodsno.isweb='Y'  and goodtype.isweb='Y' and goodmate.isweb='Y'";

            ls_SQL += WebSet.GetShowGood_SQL("all");
            n_findby_dw lnv_find = new n_findby_dw();

            lnv_find.of_setSQL(ls_SQL);
            lnv_find.of_SetOr("Txt_GoodNo", "goo_no", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "GyNo", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "goo_name", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "barcode", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "content", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "CAST(saleprice as varchar(50))", "like", Txt_GoodNo.Text);
            lnv_find.of_SetCol("goo_mate", "goodsno.goo_mate", "=", DDL_GooMate.SelectedValue.Trim());
            lnv_find.of_SetCol("goo_type", "goodsno.goo_type", "=", DDL_GooType.SelectedValue.Trim());

            int       count     = 0;
            DataTable ldt_Goods = lnv_find.Of_GetPageDataTable("goodsno.goo_code", gi_PageSize, li_PageIndex, ref count);//PageDAL.Page(Page, baseclass.GysoftParameter.ChangeParameter(ll_Pa), out count);

            Log.WriteTextLog("Dw_OrderCarSql", "Log", lnv_find.AllSQL + "  sql=" + ls_SQL, 9);
            if (li_PageIndex == 1)
            {
                if (count % gi_PageSize != 0)
                {
                    Lbl_PageCount.Text = ((count / gi_PageSize) + 1).ToString();
                }
                else
                {
                    Lbl_PageCount.Text = (count / gi_PageSize).ToString();
                }
            }

            #region 添加价格和采购量
            Hashtable Hash = Shoping.GetHash();
            for (int li_Rows = 0; li_Rows < ldt_Goods.Rows.Count; li_Rows++)
            {
                string ls_Price = UserInfo.ShowGoo_price(ldt_Goods.Rows[li_Rows]["goo_code"],
                                                         ldt_Goods.Rows[li_Rows]["getdetail_memo"]);
                Decimal lde_Price = 0;
                try { lde_Price = Convert.ToDecimal(ls_Price); }
                catch
                {
                    ldt_Goods.Rows[li_Rows]["UserPrice"] = 0.00;
                    continue;
                }
                ldt_Goods.Rows[li_Rows]["UserPrice"] = lde_Price;
                if (Hash.ContainsKey(ldt_Goods.Rows[li_Rows]["goo_code"].ToString().Trim()))
                {
                    try
                    {
                        Decimal num    = Convert.ToDecimal(Hash[ldt_Goods.Rows[li_Rows]["goo_code"].ToString().Trim()]);
                        int     li_num = Convert.ToInt32(Decimal.Round(num, 0));
                        ldt_Goods.Rows[li_Rows]["num"]   = li_num;
                        ldt_Goods.Rows[li_Rows]["piece"] = li_num / Convert.ToDecimal(ldt_Goods.Rows[li_Rows]["specnum"]);
                    }
                    catch {
                        ldt_Goods.Rows[li_Rows]["num"]   = 0;
                        ldt_Goods.Rows[li_Rows]["piece"] = 0;
                    }
                }
            }
            #endregion

            if (Convert.ToInt32(Lbl_PageCount.Text) > 1)
            {
                Pages.Visible = true;
            }
            else
            {
                Pages.Visible = false;
            }


            Rep_GoodsNo.DataSource = ldt_Goods;
            Rep_GoodsNo.DataBind();
        }
        private void Of_bind_Goods()
        {
            int li_PageIndex = 1;

            try { li_PageIndex = Convert.ToInt32(Lbl_PageIndex.Text); }
            catch { }

            //isnull((select memo from Goodsno_picture where Goo_code=goodsno.goo_code),'')as memo,
            string ls_SQL = @"select isnull((select ThumbnaiIimg from Goodsno_picture where Goo_code=goodsno.goo_code),'img/error.png')as ThumbnaiIimg,
                            goo_code,goo_no,specnum,Goo_Type,Goo_Mate,goo_name,0.00 as UserPrice,Spec,
                            Content,Goo_unit,getdetail_memo,0 as num,0 as piece,'' as lasttime,saleprice,'' as discount
                            from goodsno where 1=1 and isnull(goo_mate,'')<>'PR' and goo_code in 
                            ( select goods_code 
                            from outone,outmany
                            where outone.out_no=outmany.out_no
                            and outone.cus_code ='#cus_code'
                            and outone.out_date >='#out_date' 
                            group by goods_code
                            )  order by goo_name";

            //GysoftParameter[] Pa ={new GysoftParameter("@cus_code",SysVisitor.Current.UserCode),
            //                     new GysoftParameter("@out_date",DateTime.Now.AddYears(-1).ToString())};
            ls_SQL = ls_SQL.Replace("#cus_code", SysVisitor.Current.UserCode);
            ls_SQL = ls_SQL.Replace("#out_date", DateTime.Now.AddYears(-1).ToString());

            n_findby_dw lnv_find = new n_findby_dw();

            lnv_find.of_setSQL(ls_SQL);

            lnv_find.of_SetOr("Txt_GoodNo", "goo_no", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "GyNo", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "goo_name", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "barcode", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "content", "like", Txt_GoodNo.Text);
            lnv_find.of_SetOr("Txt_GoodNo", "CAST(saleprice as varchar(50))", "like", Txt_GoodNo.Text);

            lnv_find.of_SetCol("DDL_GooMate", "goo_mate", "=", DDL_GooMate.SelectedValue.ToString());
            lnv_find.of_SetCol("DDL_GooType", "goo_type", "=", DDL_GooMate.SelectedValue.ToString());

            int       count     = 0;
            DataTable ldt_Goods = new DataTable();

            ldt_Goods = lnv_find.Of_GetPageDataTable("goodsno.goo_code", gi_PageSize, li_PageIndex, ref count);

            if (li_PageIndex == 1)
            {
                if (count % gi_PageSize != 0)
                {
                    Lbl_PageCount.Text = ((count / gi_PageSize) + 1).ToString();
                }
                else
                {
                    Lbl_PageCount.Text = (count / gi_PageSize).ToString();
                }
            }

            #region 添加价格和采购量
            Hashtable Hash = Shoping.GetHash();
            for (int li_Rows = 0; li_Rows < ldt_Goods.Rows.Count; li_Rows++)//discount
            {
                string ls_goodcode;
                ls_goodcode = ldt_Goods.Rows[li_Rows]["goo_code"].ToString().Trim();
                string ls_getdetail_memo;
                ls_getdetail_memo = ldt_Goods.Rows[li_Rows]["getdetail_memo"].ToString();
                string ls_key_goodcode;
                ls_key_goodcode = SysVisitor.Current.UserCode + "." + ls_goodcode + ".price";
                string ls_Price;
                ls_Price = GyRedis.GyRedis.Get(ls_key_goodcode, "");
                if (ls_Price == "")
                {
                    ls_Price = UserInfo.ShowGoo_price(ls_goodcode, ls_getdetail_memo);
                    GyRedis.GyRedis.Set(ls_key_goodcode, ls_Price);
                }
                Decimal lde_Price = 0;
                try { lde_Price = Convert.ToDecimal(ls_Price); }
                catch
                {
                    ldt_Goods.Rows[li_Rows]["UserPrice"] = 0.00;
                    continue;
                }
                ldt_Goods.Rows[li_Rows]["UserPrice"] = lde_Price;
                if (Hash.ContainsKey(ldt_Goods.Rows[li_Rows]["goo_code"].ToString().Trim()))
                {
                    try
                    {
                        Decimal num    = Convert.ToDecimal(Hash[ldt_Goods.Rows[li_Rows]["goo_code"].ToString().Trim()]);
                        int     li_num = Convert.ToInt32(Decimal.Round(num, 0));
                        ldt_Goods.Rows[li_Rows]["num"]   = li_num;
                        ldt_Goods.Rows[li_Rows]["piece"] = li_num / Convert.ToDecimal(ldt_Goods.Rows[li_Rows]["specnum"]);
                    }
                    catch
                    {
                        ldt_Goods.Rows[li_Rows]["num"]   = 0;
                        ldt_Goods.Rows[li_Rows]["piece"] = 0;
                    }
                }
                //获取折扣率
                //string ls_Discount = UserInfo.ShowGoo_price(ldt_Goods.Rows[li_Rows]["goo_code"],
                //            ldt_Goods.Rows[li_Rows]["getdetail_memo"], "discount");
                //ldt_Goods.Rows[li_Rows]["discount"] = ls_Discount.Substring(0,3);
                //string ls_SalePrice = ldt_Goods.Rows[li_Rows]["saleprice"].ToString();
                //Decimal lde_SalePrice = 0;
                //try { lde_SalePrice = Convert.ToDecimal(ls_SalePrice); }
                //catch { }
                //ldt_Goods.Rows[li_Rows]["saleprice"] = lde_SalePrice.ToString("f2");
            }
            #endregion

            #region 取得最后订货时间

            for (int li_Rows = 0; li_Rows < ldt_Goods.Rows.Count; li_Rows++)
            {
                string ls_goodcode;
                ls_goodcode = ldt_Goods.Rows[li_Rows]["goo_code"].ToString().Trim();
                string ls_key_goodcode;
                ls_key_goodcode = SysVisitor.Current.UserCode + "." + ls_goodcode;

                string ls_LastTime;
                ls_LastTime = GyRedis.GyRedis.Get(ls_key_goodcode, "");
                if (ls_LastTime == "")
                {
                    ls_LastTime = UserInfo.ShowLastTime(ls_goodcode);
                    GyRedis.GyRedis.Set(ls_key_goodcode, ls_LastTime);
                }

                try
                {
                    DateTime dt = Convert.ToDateTime(ls_LastTime);
                    ls_LastTime = dt.ToString("yyyy-MM-dd");
                }
                catch
                {
                    ls_LastTime = "";
                }
                ldt_Goods.Rows[li_Rows]["lasttime"] = ls_LastTime;
            }

            if (Convert.ToInt32(Lbl_PageCount.Text) > 1)
            {
                Pages.Visible = true;
            }
            else
            {
                Pages.Visible = false;
            }
            #endregion

            //#region 对图文信息进行转义
            //for (int i = 0; i < ldt_Goods.Rows.Count; i++)
            //{
            //    ldt_Goods.Rows[i]["memo"] = SysVisitor.GetFormatHtmlStr(ldt_Goods.Rows[i]["memo"].ToString());
            //}
            //#endregion

            Rep_GoodsNo.DataSource = ldt_Goods;
            Rep_GoodsNo.DataBind();
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Encoding gb2312 = Encoding.GetEncoding("gb2312");

            Response.ContentEncoding = gb2312;

            #region 处理Post请求
            if (Request.RequestType == "POST")
            {
                GyShop_Page.SetSession();
                string Edit     = Request.Form["Edit"].ToString();
                string scr      = Request.Form["imgscr"].ToString();//缩略图路径
                string user     = Request.Form["username"].ToString();
                string passwd   = Request.Form["password"].ToString();
                string goods_no = Request.Form["goods_no"].ToString();
                string text     = Server.UrlDecode(Request.Form["text"].ToString());
                text = HttpUtility.UrlDecode(text, Encoding.GetEncoding("UTF-8"));

                string str = SureSaleInfo(user, passwd, as_Code);//SaleInfo.SureSaleInfo(user, passwd);

                #region 保存产品图文详情
                if (str == "OK" && Edit == "false" || Edit == "true")
                {
                    int count = 0;
                    count = SqlHelper.ExecuteScalarNum("select count(*) from Goodsno_picture where Goo_code=@Goo_code", "@Goo_code=" + goods_no);
                    n_create_sql lnv_sql = new n_create_sql();
                    lnv_sql.of_SetTable("Goodsno_picture");
                    if (count <= 0)
                    {
                        lnv_sql.of_AddCol("Goo_code", goods_no);
                    }
                    lnv_sql.of_AddCol("Memo", text);
                    lnv_sql.of_AddCol("Human", user);
                    lnv_sql.of_AddCol("Insdate", DateTime.Now.ToString());
                    lnv_sql.of_AddCol("Same_code", "");
                    if (scr != "")
                    {
                        lnv_sql.of_AddCol("ThumbnaiIimg", scr);
                    }
                    int li_count = 0;
                    if (count <= 0)
                    {
                        li_count = lnv_sql.of_execute();//insert
                    }
                    else
                    {
                        li_count = lnv_sql.of_execute("Goo_code=@Goo_code", "@Goo_code=" + goods_no);//update
                    }
                    if (li_count > 0)
                    {
                        Response.Write("OK");
                    }
                    else
                    {
                        Response.Write("Error");
                    }
                    return;
                }
                #endregion

                if (str == "OK" && Edit == "DefaulePictrueAdd")//增加首页轮播图
                {
                    string            strSql = "insert into mysysset(itemType,itemName,itemvalue,memo) values('微信商城焦点图',@itemName,@itemvalue,@memo)";
                    GysoftParameter[] Pa     = { new GysoftParameter("@itemName", goods_no), //title
                                                 new GysoftParameter("@itemvalue", scr),     //Pictrue
                                                 new GysoftParameter("@memo", text) };       //href
                    int li_Rel = 0;
                    li_Rel = SqlHelper.ExecuteNonQuery(strSql, Pa);
                    if (li_Rel > 0)
                    {
                        Response.Write("OK");
                    }
                    else
                    {
                        Response.Write("Error;可能标题重复");
                    }
                    return;
                }
                if (str == "OK" && Edit == "DefaulePictrueDel")//删除首页轮播图
                {
                    string            StrSql = "DELETE from mysysset WHERE itemType='微信商城焦点图' AND itemvalue=@itemvalue";
                    GysoftParameter[] Pa     = { new GysoftParameter("@itemvalue", scr) };
                    int li_Rel = SqlHelper.ExecuteNonQuery(StrSql, Pa);
                    if (li_Rel > 0)
                    {
                        Response.Write("OK");
                    }
                    else
                    {
                        Response.Write("Error");
                    }

                    return;
                }
                else
                {
                    str = HttpUtility.UrlDecode(str, Encoding.GetEncoding("UTF-8"));
                    Response.Write(str);
                    return;
                }
            }
            #endregion

            #region 处理Get请求
            GyShop_Page.SetSession();
            url = HttpContext.Current.Request.Url.Query;
            string username = Request["username"];
            string password = Request["password"];
            string code1    = Request["code"];
            string askey    = Request["askey"];
            string ls_Rel   = "Error";
            if (Request["askey"] == null)
            {
                if (url == "" || Request["username"] == null || Request["password"] == null)
                {
                    Response.Write("Error");
                    return;
                }
                ls_Rel = SureSaleInfo(username, password, code1);//SaleInfo.SureSaleInfo(username, password);
                if (ls_Rel == "OK" && askey == null)
                {
                    string ls_isdebug = ConfigurationManager.AppSettings["debug"].ToString();
                    if (ls_isdebug == "Y")
                    {
                        Response.Write("软件正在维护中,请稍后再试");
                        return;
                    }
                    Response.Write("OK");
                    return;
                }
                else
                {
                    Response.Write(ls_Rel);
                }
            }
            else if (askey != null)
            {
                try
                {
                    askey = baseclass.DES.of_DecryStrVc(askey, Key);
                }
                catch
                {
                    Response.Write("参数不能被识别");
                    return;
                }
                askey = HttpUtility.UrlDecode(askey, Encoding.GetEncoding("UTF-8"));
                if (askey == "menu")//拉取商品种类列表
                {
                    string    sql = "Select typeNo,typeName From goodtype Where isWeb='Y' And isnull(visible,'Y')='Y' order by seq";
                    DataTable dt  = SqlHelper.ExecuteDataTable(sql);
                    string    str = Json.DataTableToJson(dt);
                    Response.Write(str);
                    return;
                }
                if (askey == "DefaultPicture")//拉取首页图片
                {
                    string    strSql     = "select itemName,itemvalue,memo from mysysset where itemType='微信商城焦点图' order by itemName desc";
                    DataTable ldt_PPTBox = SqlHelper.ExecuteDataTable(strSql);
                    string    str        = Json.DataTableToJson(ldt_PPTBox);
                    Response.Write(str);
                    return;
                }
                else
                {
                    string[] str = askey.Split('|');
                    #region 拉取产品信息列表
                    if (str.Length == 3)
                    {
                        string row          = str[0].Trim();
                        string menu         = str[1].Trim();
                        string name         = str[2].Trim();
                        int    li_PageIndex = 1;

                        string      ls_sql  = @"select goodsno.goo_name,goodsno.goo_code,goodsno.goo_no 
                                        from goodsno,goodmate,goodtype 
                                        where 1=1 
                                        and goo_type=typeno and goo_mate*=matecode and goodsno.Goodfunc in ('C','X') 
                                        and goodtype.isweb='Y' and goodmate.isweb='Y' and goodsno.isweb='Y'";
                        n_findby_dw lnv_sql = new n_findby_dw();
                        lnv_sql.of_setSQL(ls_sql);
                        lnv_sql.of_SetOr("goo_no", "goodsno.goo_no", "like", name);
                        lnv_sql.of_SetOr("goo_no", "goodsno.goo_name", "like", name);
                        lnv_sql.of_SetCol("goo_type", "goodsno.goo_type", "=", menu);

                        int       count     = 0;
                        DataTable ldt_Goods = new DataTable();
                        ldt_Goods = lnv_sql.Of_GetPageDataTable("goodsno.goo_code", Convert.ToInt32(row), li_PageIndex, ref count);
                        string str_dt = Json.DataTableToJson(ldt_Goods);
                        Response.Write(str_dt);
                        return;
                    }
                    #endregion

                    #region 为经销商微信生成初始密码,获取初始密码
                    if (str.Length == 4)
                    {
                        string generate = str[0].Trim();
                        string value    = str[1].Trim();
                        string user     = str[2].Trim();
                        string passwd   = str[3].Trim();
                        string code     = as_Code;

                        ls_Rel = SureSaleInfo(user, passwd, code);
                        if (ls_Rel == "OK")
                        {
                            return;                                       //此接口不再使用

                            if (generate == "generate" && value == "set") //校验值set为生成密码操作 get为获取密码操作
                            {
                                string ls_sql   = "select count(*) WeixinPwd from customer where WeixinPwd is null";
                                string ls_Temp  = SqlHelper.ExecuteScalar(ls_sql);
                                int    ls_count = 0;
                                try
                                { ls_count = Convert.ToInt32(ls_Temp); }
                                catch { ls_count = 0; }
                                if (ls_count == 0)//不存在值为空的密码列
                                {
                                    Response.Write("1"); return;
                                }
                                try
                                {
                                    int    RandKey = 0;
                                    Random ran     = new Random();//Random对象放在循环外面,否则大概率重复
                                    for (int i = 0; i < ls_count; i++)
                                    {
                                        RandKey = ran.Next(1000, 9999);
                                        string            WeixinPwd = baseclass.DES.of_EncryStrVc(RandKey.ToString(), ls_DESKey);
                                        string            ls_Sql    = "set rowcount 1 update customer set WeixinPwd=@WeixinPwd where WeixinPwd is null";
                                        GysoftParameter[] Pa        = { new GysoftParameter("@WeixinPwd", WeixinPwd) };
                                        SqlHelper.ExecuteNonQuery(ls_Sql, Pa);
                                    }
                                    Response.Write("0");
                                    return;
                                }
                                catch (Exception ex)
                                { Response.Write(ex.Message); return; }
                            }
                            if (generate == "generate" && value == "get")//获取经销商初始密码
                            {
                                string    ls_Sql  = "select mobile,WeixinPwd from customer";
                                DataTable ldt_pwd = SqlHelper.ExecuteDataTable(ls_Sql);
                                string    ls_pwd  = Json.DataTableToJson(ldt_pwd);
                                Response.Write(ls_pwd);
                                return;
                            }
                        }
                    }
                    #endregion

                    #region 获取产品图文详情

                    string[] str1 = askey.Split('!');
                    if (str1.Length == 3)
                    {
                        string goocode = str1[0].Trim();
                        string user    = str1[1].Trim();
                        string passwd  = str1[2].Trim();
                        string code    = as_Code;
                        ls_Rel = SureSaleInfo(user, passwd, code);
                        if (ls_Rel == "OK")
                        {
                            string            ls_Sql = "select Memo from Goodsno_picture where Goo_code=@Goo_code";
                            GysoftParameter[] Pa     =
                            {
                                new GysoftParameter("@Goo_code", goocode)
                            };
                            //DataTable ldt_user = SqlHelper.ExecuteDataTable(CommandType.Text, ls_Sql, Pa);
                            //string ls_json = Json.DataTableToJson(ldt_user);
                            //if (ls_json == "[]")
                            //{ Response.Write(""); }
                            //else
                            //Response.Write(ls_json);
                            string ldt_user = SqlHelper.ExecuteScalar(ls_Sql, Pa);
                            Response.Write(ldt_user);
                            return;
                        }
                    }

                    #endregion
                    else
                    {
                        Response.Write("error" + "key:" + Key + "  askey:" + askey); return;
                    }
                }
            }
            #endregion
        }