Example #1
0
        /// <summary>
        /// 新增药师回拨
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int AddProductOutBook(ProductOutBookInfo info)
        {
            string    sqlCommand = "ProductOutBook_Insert";
            DbCommand dbCommand  = dbw.GetStoredProcCommand(sqlCommand);

            dbw.AddOutParameter(dbCommand, "OutID", DbType.Int32, 4);
            dbw.AddInParameter(dbCommand, "ProductID", DbType.Int32, info.ProductID);
            dbw.AddInParameter(dbCommand, "ProductName", DbType.String, info.ProductName);
            dbw.AddInParameter(dbCommand, "ProductCode", DbType.String, info.ProductCode);
            dbw.AddInParameter(dbCommand, "TradePrice", DbType.Decimal, info.TradePrice);
            dbw.AddInParameter(dbCommand, "Name", DbType.String, info.Name);
            dbw.AddInParameter(dbCommand, "UID", DbType.Int32, info.UID);
            dbw.AddInParameter(dbCommand, "Mobile", DbType.String, info.Mobile);
            dbw.AddInParameter(dbCommand, "Message", DbType.String, info.Message);
            dbw.AddInParameter(dbCommand, "Quantity", DbType.Int32, info.Quantity);
            dbw.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, info.CreateTime);
            dbw.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, info.UpdateTime);
            dbw.AddInParameter(dbCommand, "Status", DbType.Int16, info.Status);
            dbw.AddInParameter(dbCommand, "HasBuy", DbType.Int16, info.HasBuy);
            dbw.ExecuteNonQuery(dbCommand);
            return(int.Parse(dbw.GetParameterValue(dbCommand, "OutID").ToString()));
        }
 /// <summary>
 /// 新增药师回拨
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public int Add(ProductOutBookInfo info)
 {
     return(dal.AddProductOutBook(info));
 }
Example #3
0
        /// <summary>
        /// ProductOutBook 数据获取
        /// </summary>
        /// <param name="tbName"></param>
        static void SQLProductOutBook_Insert()
        {
            DateTime crrTime = DateTime.Now;

            sucessSum = 0;
            errorSum  = 0;
            Console.WriteLine(string.Format("========================= BEGIN ProductOutBook"));
            try
            {
                //  查询待同步数据
                DataTable dTable = OrdersBLL.Instance.GetList(0, beginTime.ToString(), 0, 0, "ProductOutBook");
                if (dTable == null || dTable.Rows.Count <= 0)
                {
                    ConsoleMsg("ProductOutBook 有0条数据等待同步");
                }
                else
                {
                    ConsoleMsg(string.Format("ProductOutBook 有{0}条数据等待同步", dTable.Rows.Count));
                }
                //  同步数据
                ProductOutBookInfo info = null;
                foreach (DataRow row in dTable.Rows)
                {
                    //  转换数据
                    try
                    {
                        info = new ProductOutBookInfo()
                        {
                            Status = 0, HasBuy = 0
                        };
                        info.ProductID   = int.Parse(row["ProductID"].ToString());
                        info.ProductName = row["ProductName"].ToString();
                        info.ProductCode = row["ProductCode"].ToString();
                        info.TradePrice  = (string.IsNullOrEmpty(row["TradePrice"].ToString())) ? 0 : decimal.Parse(row["TradePrice"].ToString());
                        info.Name        = row["UserName"].ToString();
                        info.UID         = int.Parse(row["UID"].ToString());
                        info.Mobile      = row["Mobile"].ToString();
                        info.Message     = string.Format("{1} {0}", (row["Type"].ToString() == "1") ? "申请药师回拨" : "缺货登记", row["Message"].ToString());
                        info.Quantity    = (string.IsNullOrEmpty(row["Quantity"].ToString())) ? 0 : int.Parse(row["Quantity"].ToString());
                        info.CreateTime  = DateTime.Parse(row["CreateTime"].ToString());
                        info.UpdateTime  = crrTime;
                    }
                    catch (Exception ex)
                    {
                        errorSum++;
                        ConsoleMsg(string.Format("ProductOutBook 数据:{0} Mobile:{1} 转换失败:{2}", row["ProductID"].ToString(), row["Mobile"].ToString(), ex.Message));
                        continue;
                    }

                    //  保存
                    try
                    {
                        int outId = ProductOutBookSqlBLL.Instance.Add(info);
                        if (outId > 0)
                        {
                            sucessSum++;
                        }
                        else
                        {
                            errorSum++;
                            ConsoleMsg(string.Format("ProductOutBook 数据:{0} Mobile:{1} 保存失败", info.ProductID, info.Mobile));
                        }
                    }
                    catch (Exception ex)
                    {
                        errorSum++;
                        ConsoleMsg(string.Format("ProductOutBook 数据:{0} Mobile:{1} 保存失败:{2}", info.ProductID, info.Mobile, ex.Message));
                    }
                }
                ConsoleMsg(string.Format("ProductOutBook 同步完成:{0} 失败:{1}", sucessSum, errorSum));
            }
            catch (Exception ex)
            {
                ConsoleMsg(string.Format("ProductOutBook ERROR:{0}", ex.Message));
            }
            Console.WriteLine("========================= END ProductOutBook\r\n");
            Console.WriteLine("\r\n");
        }