public List <Model.goods_std> GetData()
        {
            var lst = new List <Model.goods_std>();

            foreach (DataGridViewRow row in this.dataGridView1.Rows)
            {
                if ((row.Cells[4].Value != null && row.Cells[4].Value.ToString() != ""))
                {
                    var std = new Model.goods_std();
                    if (row.Cells[1].Value.ToString().ToLower() == "true".ToLower())
                    {
                        std.is_default = "1";
                    }
                    else
                    {
                        std.is_default = "0";
                    }

                    decimal p1  = Conv.ToDecimal(row.Cells[2].Value.ToString());
                    decimal p2  = Conv.ToDecimal(row.Cells[3].Value.ToString());
                    decimal p3  = Conv.ToDecimal(row.Cells[4].Value.ToString());
                    float   qty = Conv.ToFloat(row.Cells[5].Value.ToString());

                    std.prices = p1 + "," + p2 + "," + p3 + ",,";
                    std.qty    = qty;
                    lst.Add(std);
                }
            }
            //
            int flag = 0;

            foreach (Model.goods_std std in lst)
            {
                if (std.is_default == "1")
                {
                    flag = 1;
                }
            }
            if (flag == 0)
            {
                if (lst.Count != 0)
                {
                    lst[0].is_default = "1";
                }
            }
            return(lst);
        }
Beispiel #2
0
        void IGoods.GetInfo(string goods_no, out string goods_id, out string new_goods_no, out string goods_name, out string long_name, out string cls_id, out string cls_name,
                            out string small_img_url, out string small_img_full_url, out string large_img_url, out string large_img_full_url, out string detail_img_url,
                            out string detail_img_full_url, out string themes, out string text, out string status, out string is_show_mall, out List <Model.goods_std> lststd)
        {
            var req  = new Request();
            var json = req.request("/goods?t=get_info_by_no", "{\"goods_no\":\"" + goods_no + "\"}");

            ReadWriteContext.IReadContext read = new ReadWriteContext.ReadContextByJson(json);
            if (read.Read("errId") != "0")
            {
                throw new Exception(read.Read("errMsg"));
            }
            goods_id            = read.Read("goods_id");
            new_goods_no        = read.Read("goods_no");
            goods_name          = read.Read("goods_name");
            long_name           = read.Read("long_name");
            cls_id              = read.Read("cls_id");
            cls_name            = read.Read("cls_name");
            small_img_url       = read.Read("small_img_url");
            small_img_full_url  = read.Read("small_img_full_url");
            large_img_url       = read.Read("large_img_url");
            large_img_full_url  = read.Read("large_img_full_url");
            detail_img_url      = read.Read("detail_img_url");
            detail_img_full_url = read.Read("detail_img_full_url");
            themes              = read.Read("themes");
            text         = read.Read("text");
            status       = read.Read("status");
            is_show_mall = read.Read("is_show_mall");
            List <Model.goods_std> lsttmp = new List <Model.goods_std>();

            if (read.Read("datas") != "")
            {
                foreach (ReadWriteContext.IReadContext r in read.ReadList("datas"))
                {
                    var std = new Model.goods_std();
                    std.prices     = r.Read("prices");
                    std.is_default = r.Read("is_default");
                    float qty = Conv.ToFloat(r.Read("qty"));
                    std.qty = qty;
                    lsttmp.Add(std);
                }
            }
            lststd = lsttmp;
        }