//添加购买记录 private void btnAdd_Click(object sender, EventArgs e) { string time = DateTime.Now.ToString(); string[] str = time.Split(new char[] { '/', ' ' }, StringSplitOptions.RemoveEmptyEntries); string timeNew = cbbYear.Text + "-" + cbbMonth.Text + "-" + cbbDay.Text + " " + str[3]; GouMaiJiLu gmjl = new GouMaiJiLu(); if (rdoBen.Checked == false && rdoZei.Checked == false) { MessageBox.Show("请选择大款!"); return; } gmjl.PId = rdoZei.Checked ? 1 : 0; gmjl.PDate = DateTime.Parse(timeNew); decimal money; if (decimal.TryParse(txtMoney.Text, out money)) { gmjl.PMoney = money; } else { MessageBox.Show("请输入正确的金额,silly b!"); return; } if (prb.Add(gmjl)) { LoadList(); LoadTongJiMonth(); LoadTongJiYear(); txtMoney.Text = ""; } }
//添加购买记录 public int insert(GouMaiJiLu gmjl) { string sql = "insert into Records(pid,pmoney,pdate,pdelflag) values(@pid,@pmoney,@pdate,1)"; SQLiteParameter[] paras = { new SQLiteParameter("@pid", gmjl.PId), new SQLiteParameter("@pmoney", gmjl.PMoney), new SQLiteParameter("@pdate", gmjl.PDate) }; return(SqliteHelper.ExecuteNonQuery(sql, paras)); }
//添加购买记录 public bool Add(GouMaiJiLu gmjl) { return(prd.insert(gmjl) > 0); }