/// <summary> /// 得到一个对象实体 /// </summary> public Model.ReportAccounts GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,ApplyTime,SettlementCycle,Recharge,Income,Settlement,Status,ActualPlay,UserID,UserName,Bak1,Bak2,Bak3 from ReportAccounts "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; Model.ReportAccounts model = new Model.ReportAccounts(); DataSet ds = DbHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.ReportAccounts DataRowToModel(DataRow row) { Model.ReportAccounts model = new Model.ReportAccounts(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["ApplyTime"] != null && row["ApplyTime"].ToString() != "") { model.ApplyTime = DateTime.Parse(row["ApplyTime"].ToString()); } if (row["SettlementCycle"] != null) { model.SettlementCycle = row["SettlementCycle"].ToString(); } if (row["Recharge"] != null && row["Recharge"].ToString() != "") { model.Recharge = decimal.Parse(row["Recharge"].ToString()); } if (row["Income"] != null && row["Income"].ToString() != "") { model.Income = decimal.Parse(row["Income"].ToString()); } if (row["Settlement"] != null && row["Settlement"].ToString() != "") { model.Settlement = decimal.Parse(row["Settlement"].ToString()); } if (row["Status"] != null) { model.Status = row["Status"].ToString(); } if (row["ActualPlay"] != null && row["ActualPlay"].ToString() != "") { model.ActualPlay = decimal.Parse(row["ActualPlay"].ToString()); } if (row["UserID"] != null && row["UserID"].ToString() != "") { model.UserID = int.Parse(row["UserID"].ToString()); } if (row["UserName"] != null) { model.UserName = row["UserName"].ToString(); } if (row["Bak1"] != null) { model.Bak1 = row["Bak1"].ToString(); } if (row["Bak2"] != null) { model.Bak2 = row["Bak2"].ToString(); } if (row["Bak3"] != null) { model.Bak3 = row["Bak3"].ToString(); } } return model; }
protected void btnSave_Click(object sender, EventArgs e) { if (consumeMoney.Text == "0") { string myScript = @"alertMsg('没有充值记录!','error.gif');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", myScript, true); return; } else { try { Spread.Model.ReportAccounts accModel = new Model.ReportAccounts(); accModel.ApplyTime = DateTime.Now; accModel.UserID = int.Parse(hduserid.Value); accModel.UserName = hdusername.Value; accModel.SettlementCycle = this.startDate.Text + "~" + this.endDate.Text; accModel.Recharge = Decimal.Parse(consumeMoney.Text); accModel.Income = Decimal.Parse(validMoney.Text); accModel.Settlement = 0; accModel.Status = "待审核"; accModel.ActualPlay = 0; accModel.Bak1 = "全部渠道"; accBll.Add(accModel); string myScript = @"alertRedirectMsg('申请成功!','success.gif','individualbal.aspx');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", myScript, true); } catch { string myScript = @"alertMsg('申请失败!','error.gif');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", myScript, true); } //accBll.Add } }