/// <summary> /// 增加一条数据 /// </summary> public int Add(TSM.Model.CK_Payment model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into CK_Payment("); strSql.Append("CK_PeopleID,CK_PayDate,CK_PayMoney,CK_PayComment)"); strSql.Append(" values ("); strSql.Append("@CK_PeopleID,@CK_PayDate,@CK_PayMoney,@CK_PayComment)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CK_PeopleID", SqlDbType.Int,4), new SqlParameter("@CK_PayDate", SqlDbType.DateTime), new SqlParameter("@CK_PayMoney", SqlDbType.Decimal,9), new SqlParameter("@CK_PayComment", SqlDbType.VarChar,100)}; parameters[0].Value = model.CK_PeopleID; parameters[1].Value = model.CK_PayDate; parameters[2].Value = model.CK_PayMoney; parameters[3].Value = model.CK_PayComment; object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters); if (obj == null) { return 1; } else { return Convert.ToInt32(obj); } }
private void LoadData() { btnClose.OnClientClick = ActiveWindow.GetHideReference(); DataSet ds = m_bllCK_People.GetList(""); DropDownListPeople.DataTextField = "CK_PeopleName"; DropDownListPeople.DataValueField = "CK_PeopleID"; DropDownListPeople.DataSource = ds.Tables[0]; DropDownListPeople.DataBind(); DropDownListPeople.SelectedIndex = 0; int id = GetQueryIntValue("id"); TSM.Model.CK_Payment modelCK_Payment = m_bllCK_Payment.GetModel(id); if (modelCK_Payment == null) { // 参数错误,首先弹出Alert对话框然后关闭弹出窗口 Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference()); return; } tbxNote.Text = modelCK_Payment.CK_PayComment; DropDownListPeople.SelectedValue = modelCK_Payment.CK_PeopleID.ToString(); tbxCount.Text = modelCK_Payment.CK_PayMoney.ToString(); DatePicker1.SelectedDate = modelCK_Payment.CK_PayDate; //tbxName.Text = modelCK_Payment.CK_PaymentName; //tbxPhoneNo.Text = modelCK_Payment.CK_PhoneNo; //tbxNote.Text = modelCK_Payment.CK_Comment; }
private void SavePayment() { TSM.Model.CK_Payment modelCK_Payment = new TSM.Model.CK_Payment(); modelCK_Payment.CK_PeopleID = int.Parse(DropDownListPeople.SelectedValue); modelCK_Payment.CK_PayMoney = decimal.Parse(tbxCount.Text.Trim()); modelCK_Payment.CK_PayDate = (DateTime)DatePicker1.SelectedDate; modelCK_Payment.CK_PayComment = tbxNote.Text.Trim(); m_bllCK_Payment.Add(modelCK_Payment); }
private void SavePayment() { TSM.Model.CK_Payment modelCK_Payment = new TSM.Model.CK_Payment(); modelCK_Payment.CK_PeopleID = int.Parse(DropDownListPeople.SelectedValue); modelCK_Payment.CK_PayMoney = decimal.Parse(tbxCount.Text.Trim()); modelCK_Payment.CK_PayDate = (DateTime)DatePicker1.SelectedDate; modelCK_Payment.CK_PayComment = tbxNote.Text.Trim(); m_bllCK_Payment.Add(modelCK_Payment); }
protected void btnSaveClose_Click(object sender, EventArgs e) { int id = GetQueryIntValue("id"); TSM.Model.CK_Payment modelCK_Payment = m_bllCK_Payment.GetModel(id); modelCK_Payment.CK_PeopleID = int.Parse(DropDownListPeople.SelectedValue); modelCK_Payment.CK_PayMoney = decimal.Parse(tbxCount.Text.Trim()); modelCK_Payment.CK_PayDate = (DateTime)DatePicker1.SelectedDate; modelCK_Payment.CK_PayComment = tbxNote.Text.Trim(); m_bllCK_Payment.Update(modelCK_Payment); //FineUI.Alert.Show("保存成功!", String.Empty, FineUI.Alert.DefaultIcon, FineUI.ActiveWindow.GetHidePostBackReference()); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }
/// <summary> /// 得到一个对象实体 /// </summary> public TSM.Model.CK_Payment GetModel(int CK_PaymentID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 CK_PaymentID,CK_PeopleID,CK_PayDate,CK_PayMoney,CK_PayComment from CK_Payment "); strSql.Append(" where CK_PaymentID=@CK_PaymentID "); SqlParameter[] parameters = { new SqlParameter("@CK_PaymentID", SqlDbType.Int,4)}; parameters[0].Value = CK_PaymentID; TSM.Model.CK_Payment model=new TSM.Model.CK_Payment(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["CK_PaymentID"].ToString()!="") { model.CK_PaymentID=int.Parse(ds.Tables[0].Rows[0]["CK_PaymentID"].ToString()); } if(ds.Tables[0].Rows[0]["CK_PeopleID"].ToString()!="") { model.CK_PeopleID=int.Parse(ds.Tables[0].Rows[0]["CK_PeopleID"].ToString()); } if(ds.Tables[0].Rows[0]["CK_PayDate"].ToString()!="") { model.CK_PayDate=DateTime.Parse(ds.Tables[0].Rows[0]["CK_PayDate"].ToString()); } if(ds.Tables[0].Rows[0]["CK_PayMoney"].ToString()!="") { model.CK_PayMoney=decimal.Parse(ds.Tables[0].Rows[0]["CK_PayMoney"].ToString()); } model.CK_PayComment=ds.Tables[0].Rows[0]["CK_PayComment"].ToString(); return model; } else { return null; } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(TSM.Model.CK_Payment model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update CK_Payment set "); strSql.Append("CK_PeopleID=@CK_PeopleID,"); strSql.Append("CK_PayDate=@CK_PayDate,"); strSql.Append("CK_PayMoney=@CK_PayMoney,"); strSql.Append("CK_PayComment=@CK_PayComment"); strSql.Append(" where CK_PaymentID=@CK_PaymentID "); SqlParameter[] parameters = { new SqlParameter("@CK_PaymentID", SqlDbType.Int,4), new SqlParameter("@CK_PeopleID", SqlDbType.Int,4), new SqlParameter("@CK_PayDate", SqlDbType.DateTime), new SqlParameter("@CK_PayMoney", SqlDbType.Decimal,9), new SqlParameter("@CK_PayComment", SqlDbType.VarChar,100)}; parameters[0].Value = model.CK_PaymentID; parameters[1].Value = model.CK_PeopleID; parameters[2].Value = model.CK_PayDate; parameters[3].Value = model.CK_PayMoney; parameters[4].Value = model.CK_PayComment; DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public TSM.Model.CK_Payment GetModel(int CK_PaymentID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 CK_PaymentID,CK_PeopleID,CK_PayDate,CK_PayMoney,CK_PayComment from CK_Payment "); strSql.Append(" where CK_PaymentID=@CK_PaymentID "); SqlParameter[] parameters = { new SqlParameter("@CK_PaymentID", SqlDbType.Int,4)}; parameters[0].Value = CK_PaymentID; TSM.Model.CK_Payment model=new TSM.Model.CK_Payment(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["CK_PaymentID"].ToString()!="") { model.CK_PaymentID=int.Parse(ds.Tables[0].Rows[0]["CK_PaymentID"].ToString()); } if(ds.Tables[0].Rows[0]["CK_PeopleID"].ToString()!="") { model.CK_PeopleID=int.Parse(ds.Tables[0].Rows[0]["CK_PeopleID"].ToString()); } if(ds.Tables[0].Rows[0]["CK_PayDate"].ToString()!="") { model.CK_PayDate=DateTime.Parse(ds.Tables[0].Rows[0]["CK_PayDate"].ToString()); } if(ds.Tables[0].Rows[0]["CK_PayMoney"].ToString()!="") { model.CK_PayMoney=decimal.Parse(ds.Tables[0].Rows[0]["CK_PayMoney"].ToString()); } model.CK_PayComment=ds.Tables[0].Rows[0]["CK_PayComment"].ToString(); return model; } else { return null; } }