/// <summary> /// 增加一条数据 /// </summary> public static bool Add(M_Asset model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Asset("); strSql.Append("Personal,Credit,UpdateTime)"); strSql.Append(" values ("); strSql.Append("@Personal,@Credit,@UpdateTime)"); OleDbParameter[] parameters = { new OleDbParameter("@Personal", OleDbType.Double), new OleDbParameter("@Credit", OleDbType.Double), new OleDbParameter("@UpdateTime", OleDbType.Date) }; parameters[0].Value = model.Personal; parameters[1].Value = model.Credit; parameters[2].Value = model.UpdateTime; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public static bool Update(M_Asset model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Asset set "); strSql.Append("Personal=@Personal,"); strSql.Append("Credit=@Credit,"); strSql.Append("UpdateTime=@UpdateTime"); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@Personal", OleDbType.Double), new OleDbParameter("@Credit", OleDbType.Double), new OleDbParameter("@UpdateTime", OleDbType.Date), new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = model.Personal; parameters[1].Value = model.Credit; parameters[2].Value = model.UpdateTime; parameters[3].Value = model.ID; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public ActionResult DeleteConfirmed(long id) { M_Asset m_Asset = db.M_Asset.Find(id); db.M_Asset.Remove(m_Asset); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "AssetID,AssetNo,AssetName,UseCategory,Amount,Status,GetDate,GetReason,TransferDate,TransferReason,BelongingID,PlaceID,InsertDate,UpdateDate")] M_Asset m_Asset) { if (ModelState.IsValid) { db.Entry(m_Asset).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(m_Asset)); }
/// <summary> /// 获取资产值 /// </summary> private void GetAsset() { M_Asset mas = new M_Asset(); DataTable dt = Asset.GetList("1=1 order by UpdateTime desc").Tables[0]; if (dt.Rows.Count > 0) { mas = Asset.DataRowToModel(dt.Rows[0]); d_Asset = (mas.Personal + mas.Credit); txtAsset.Text = (mas.Personal + mas.Credit).ToString(); } }
private void FrmSetHoldingRate_Load(object sender, EventArgs e) { M_Asset mas = new M_Asset(); DataTable dt = Asset.GetList("1=1 order by UpdateTime desc").Tables[0]; if (dt.Rows.Count > 0) { mas = Asset.DataRowToModel(dt.Rows[0]); } txtCreditAsset.Text = mas.Credit.ToString(); txtPersonalAsset.Text = mas.Personal.ToString(); dtpupdateDate.Value = mas.UpdateTime; }
// GET: Asset/Delete/5 public ActionResult Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } M_Asset m_Asset = db.M_Asset.Find(id); if (m_Asset == null) { return(HttpNotFound()); } return(View(m_Asset)); }
/// <summary> /// 得到一个对象实体 /// </summary> public static M_Asset DataRowToModel(DataRow row) { M_Asset model = new M_Asset(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } model.Personal = Convert.ToDouble(row["Personal"].ToString()); model.Credit = Convert.ToDouble(row["Credit"].ToString()); if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "") { model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString()); } } return(model); }
private void btnCommit_Click(object sender, EventArgs e) { CheckData(); if (!GetData()) { return; } M_Asset mas = new M_Asset(); mas.Personal = personalAsset; mas.Credit = creditAsset; mas.UpdateTime = date; Asset.Add(mas); if (SetAsset != null) { SetAsset(); } this.Close(); }
/// <summary> /// 得到一个对象实体 /// </summary> public static M_Asset GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,Personal,Credit,UpdateTime from Asset "); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = ID; M_Asset model = new M_Asset(); DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }