protected void Page_Load(object sender, EventArgs e) { UserInfo.GetUserInfo(out as_Cus_code, out as_Cus_Name); if (!string.IsNullOrEmpty(Request.QueryString["goocode"]))//是否修改购物车 { string aa = ""; aa = Request.QueryString["goocode"]; if (aa.IndexOf('|') > 0) { try { string[] k = aa.Split('|'); if (int.Parse(k[1]) < 1000) { Shoping.UpdateShopCar(k[0], k[1], "Change"); } } catch { } } } if (!IsPostBack) { if (!UserInfo.SureUserWinxin(Request.QueryString["userweixinid"])) { Response.Redirect("Error.aspx"); } Hashtable Hash = Shoping.GetHash(); if (Hash.Count == 0) { P_Err.Visible = true; P_Good.Visible = false; } CustomerModel Model = new CustomerModel(); CustomerDAL DAL = new CustomerDAL(); Model = DAL.GetModel(as_Cus_code); Txt_Phone.Text = Model.Phone; Txt_receiveaddr.Text = Model.Cus_Address; txt_trafficadd.Text = Model.Cus_TrafficeAddr; Of_bind_ShopCar(); } }
/// <summary> /// 保存到购物车 /// </summary> private void SaveMun(DataTable ad_tab) { for (int i = 0; i < ad_tab.Rows.Count; i++) { if (!string.IsNullOrEmpty(ad_tab.Rows[i][0].ToString()) && !string.IsNullOrEmpty(ad_tab.Rows[i][1].ToString())) { string ls_GooCode = Dyeing_GooCode(Request.QueryString["goodtype"], ad_tab.Rows[i][0].ToString()); Decimal lde_Num = 0; if (Request.Form[i] != "") { try { lde_Num = Convert.ToDecimal(ad_tab.Rows[i][1].ToString()); } catch { ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('数量有误!')", true); return; } Shoping.UpdateShopCar(ls_GooCode, lde_Num, "Change"); } } } Shoping.GetHash(); }
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(); }
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_ShopCar() { Hashtable Hash = Shoping.GetHash(); StringBuilder ls_id = new StringBuilder(); foreach (string id in Hash.Keys) { if (ls_id.Length != 0) { ls_id.Append(",'" + id + "'"); } else { ls_id.Append("'" + id + "'"); } } if (ls_id.Length == 0) { return; } string StrSql = "SELECT goo_no,goo_name,goo_code,goo_type,goo_mate,0 as num,0 as piece," + "Specnum,getdetail_memo,Content,spec,0.00 as Total,Goo_unit FROM goodsno " + " where goo_code in (" + ls_id.ToString() + ") " + //WebSet.GetShowGood_SQL("Cus") + " order by goo_type,goo_no "; DataTable ldt_Goods = new DataTable(); ldt_Goods = SqlHelper.ExecuteDataTable(StrSql); DataColumn[] Keys = { ldt_Goods.Columns["goo_code"] }; ldt_Goods.PrimaryKey = Keys; Decimal ld_TotalAll = 0; foreach (string X in Hash.Keys) { try { Decimal num = Convert.ToDecimal(Hash[X]); int li_num = Convert.ToInt32(Decimal.Round(num, 0)); DataRow Dr = ldt_Goods.Rows.Find(X); Dr["num"] = li_num; Dr["piece"] = li_num / Convert.ToDecimal(Dr["specnum"]); string ls_price = UserInfo.ShowGoo_price(Dr["goo_code"], Dr["Getdetail_Memo"]); if (ls_price == "登陆可见") { continue; } Decimal price = Convert.ToDecimal(ls_price); Dr["Total"] = li_num * price; ld_TotalAll += li_num * price; } catch { } } Rep_GoodsNo.DataSource = ldt_Goods; Rep_GoodsNo.DataBind(); Lbl_TotalAll.Text = ld_TotalAll.ToString(); }
protected void IBtn_Save_Click(object sender, ImageClickEventArgs e) { Hashtable Hash = Shoping.GetHash(); if (Hash.Count == 0) { ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('你的购物车内没有商品!');", true); return; } GoodsNoDAL DAL = new GoodsNoDAL(); //创建DataTable DataTable ldt_GoodsNo = new DataTable(); ldt_GoodsNo.Columns.Add("GoodCode"); ldt_GoodsNo.Columns.Add("GooNo"); ldt_GoodsNo.Columns.Add("Num"); ldt_GoodsNo.Columns.Add("GooType"); ldt_GoodsNo.Columns.Add("GooMate"); ldt_GoodsNo.Columns.Add("Getdetail_Memo"); ldt_GoodsNo.Columns.Add("Goo_price"); #region 先转换成DataTable foreach (string id in Hash.Keys) { string ls_Goodcode = id; if (ls_Goodcode.Trim().Length == 0 || ls_Goodcode == " ") { continue; } string ls_num = Hash[id].ToString(); Decimal ld_Num; try { ld_Num = Convert.ToDecimal(ls_num); if (ld_Num <= 0) { continue; } } catch { continue; } GoodsNoModel Mode = DAL.GetShowModel(id); DataRow Dr = ldt_GoodsNo.NewRow(); Dr["GoodCode"] = Mode.Goo_code; Dr["GooNo"] = Mode.Goo_no; Dr["Num"] = ld_Num; Dr["GooType"] = Mode.Goo_type; Dr["GooMate"] = Mode.Goo_mate; Dr["Getdetail_Memo"] = Mode.Getdetail_Memo; Dr["Goo_price"] = Mode.Goo_price; if (Mode.Goo_price == "") { Log.WriteTextLog("Dw_OrderSave_Err", "Log", "GoodCode=" + Mode.Goo_code + " Getdetail_Memo=" + Mode.Getdetail_Memo, 3); ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('获取价格失败!订单无法保存');", true);//select * from dbo.uf_getcussaleprice('GD198','600001','2015-10-10','正常') return; } ldt_GoodsNo.Rows.Add(Dr); } ldt_GoodsNo.DefaultView.Sort = "GooType,GooNo"; #endregion #region 提取分单数据 DataTable ldt_Extract = new DataTable(); string ls_Extract_ID = publicfuns.of_GetMySysSet("网上商城", "分单"); if (ls_Extract_ID != "") { ldt_Extract.Columns.Add("GoodCode"); ldt_Extract.Columns.Add("GooNo"); ldt_Extract.Columns.Add("Num"); ldt_Extract.Columns.Add("GooType"); ldt_Extract.Columns.Add("GooMate"); ldt_Extract.Columns.Add("Getdetail_Memo"); ldt_Extract.Columns.Add("Goo_price"); for (int li_Rows = 0; li_Rows < ldt_GoodsNo.Rows.Count; li_Rows++) { if (ldt_GoodsNo.Rows[li_Rows]["GooMate"].ToString().Trim() == ls_Extract_ID.Trim()) { ldt_Extract.Rows.Add(ldt_GoodsNo.Rows[li_Rows].ItemArray); ldt_GoodsNo.Rows[li_Rows].Delete(); } } ldt_Extract.DefaultView.Sort = "GooType,GooNo"; } #endregion if (ldt_GoodsNo.Rows.Count > 0) { of_OrderSave(ldt_GoodsNo.DefaultView.ToTable()); } if (ldt_Extract.Rows.Count > 0) { of_OrderSave(ldt_Extract.DefaultView.ToTable()); } Shoping.Clear(); ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('保存成功,谢谢你的订单!');location.href='Dw_OrderCar.aspx?UserKey=" + UserInfo.GetUserKey() + "&userweixinid=" + SysVisitor.Current.UserWeixinID + "'", true); //IBtn_Save2.Enabled = false; //Response.Redirect("Dw_OrderCar.aspx?UserKey=" + UserInfo.GetUserKey()); }