public void WarePriceInsert(ProductPriceHistory price) { OtDB db = GetDb(); try { db.Begin(); //sqlite用的全球时间UTC,要用datetime()函数转换若干 localtime UTC //用data_time.ToString("s");这种方法转换成 iso 8601标准字符串格式 string sql = string.Format("insert into ProductPriceHistory (PID,Price,PriceDate,PriceType) select '{0}',{1},'{2}','{3}'", price.PID, price.Price, price.PriceDate.ToString("s"), price.PriceType); db.Exec(sql); db.Commit(); } catch (Exception ex) { OtCom.XLogErr(ex.Message); //db.Rollback(); } }
/// <summary> /// 插入商品价格 /// </summary> /// <param name="price">历史价格对象</param> public void WarePriceInsert(ProductPriceHistory price) { if (price != null) { WarePriceInsert(price.PID, price.Price, price.PriceDate, price.PriceType); } }
private void btnPriceAdd_Click(object sender, EventArgs e) { try { double myPrice = double.Parse(txtPrice.Text); ProductPriceHistory priceObj = new ProductPriceHistory() { PID = _myProduct.ProductID, PriceDate = datePrice.DateTime, Price = myPrice, PriceType = txtPriceType.Text }; DBHelper.GetInstance().WarePriceInsert(priceObj); RefreshPriceGrid(); } catch (Exception ex) { OtCom.XLogErr(ex.Message); } }