Ejemplo n.º 1
0
        /// <summary>
        /// 返回强类型的单据表头列表
        /// </summary>
        /// <returns></returns>
        public static List<XYSaleBill> GetSaleBillIndexs()
        {
            List<XYSaleBill> rv = new List<XYSaleBill>();

            foreach (DataRow item in GetSaleBillIndexDataTable().Rows)
            {
                XYSaleBill sb = new XYSaleBill();

                sb.token = Common.AppSetting.token;
                sb.billtype = Convert.ToInt32(item["billtype"]);
                sb.card_num = item["card_num"].ToString();
                sb.create_time = Convert.ToDateTime(item["create_time"]);
                sb.sheet_id = Convert.ToInt32(item["sheet_id"]);
                sb.dealer = item["dealer"].ToString();
                sb.store = item["store"].ToString();
                sb.desc = item["desc"].ToString();
                sb.comment = item["comment"].ToString();
                sb.total_cost = Convert.ToDouble(item["total_cost"]);
                sb.oid = Convert.ToInt32(item["oid"]);
                sb.deal_type = item["deal_type"].ToString() == "0" ? DealType.SALE : DealType.BACK;

                sb.items = GetASaleBillDetails(sb.sheet_id, sb.billtype);

                sb.PostBillInfo = GetSaleBillPostInfo(sb.sheet_id);

                rv.Add(sb);
            }

            return rv;
        }
Ejemplo n.º 2
0
        private void ddd(XYSaleBill sb)
        {
            try
            {
                string url = Common.AppSetting.httpurl;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

                request.Method = "POST";
                request.ContentType = "application/x-www-form-urlencoded";

                string postdata = "body=" + JsonConvert.SerializeObject(sb);

                UTF8Encoding code = new UTF8Encoding();  //这里采用UTF8编码方式
                byte[] data = code.GetBytes(postdata);

                request.ContentLength = data.Length;

                using (Stream stream = request.GetRequestStream()) //获取数据流,该流是可写入的
                {
                    stream.Write(data, 0, data.Length); //发送数据流
                    stream.Close();

                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                    Stream ss = response.GetResponseStream();

                    XmlTextReader Reader = new XmlTextReader(ss);
                    Reader.MoveToContent();
                    string status = Reader.ReadInnerXml();

                    if (status == "302")
                    {
                        sb.UpDatePostInfo(1);

                        Common.AppLog.CreateAppLog().Info(string.Format("编号为:{0} 的单据于 {1} 更新成功", sb.sheet_id, DateTime.Now));
                    }
                    else
                    {
                        sb.UpDatePostInfo(0);

                        Common.AppLog.CreateAppLog().Error(string.Format("编号为:{0} 的单据于 {1} 更新失败", sb.sheet_id, DateTime.Now));
                    }
                }

            }
            catch (Exception ex)
            {
                Common.AppLog.CreateAppLog().Error(ex.Message);
            }
        }