/// <summary> /// 增加一条数据 /// </summary> public int Add(DNSABC.Model.DNSABC_Invoice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into DNSABC_Invoice("); strSql.Append("UserID,InvoiceName,Price,PostType,RealName,Tel,Mobil,Address,PostCode,Remark,State,AdminRemark,CreateTime)"); strSql.Append(" values ("); strSql.Append("@UserID,@InvoiceName,@Price,@PostType,@RealName,@Tel,@Mobil,@Address,@PostCode,@Remark,@State,@AdminRemark,@CreateTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@InvoiceName", SqlDbType.VarChar, 200), new SqlParameter("@Price", SqlDbType.Int, 4), new SqlParameter("@PostType", SqlDbType.Int, 4), new SqlParameter("@RealName", SqlDbType.VarChar, 50), new SqlParameter("@Tel", SqlDbType.VarChar, 20), new SqlParameter("@Mobil", SqlDbType.VarChar, 20), new SqlParameter("@Address", SqlDbType.VarChar, 500), new SqlParameter("@PostCode", SqlDbType.VarChar, 20), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@AdminRemark", SqlDbType.VarChar, 500), new SqlParameter("@CreateTime", SqlDbType.DateTime) }; parameters[0].Value = model.UserID; parameters[1].Value = model.InvoiceName; parameters[2].Value = model.Price; parameters[3].Value = model.PostType; parameters[4].Value = model.RealName; parameters[5].Value = model.Tel; parameters[6].Value = model.Mobil; parameters[7].Value = model.Address; parameters[8].Value = model.PostCode; parameters[9].Value = model.Remark; parameters[10].Value = model.State; parameters[11].Value = model.AdminRemark; parameters[12].Value = model.CreateTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int Id) { DNSABC.BLL.DNSABC_Invoice bll = new DNSABC.BLL.DNSABC_Invoice(); DNSABC.Model.DNSABC_Invoice model = bll.GetModel(Id); this.lblId.Text = model.Id.ToString(); this.lblUserID.Text = model.UserID.ToString(); this.lblInvoiceName.Text = model.InvoiceName; this.lblPrice.Text = model.Price.ToString(); this.lblPostType.Text = model.PostType.ToString(); this.lblRealName.Text = model.RealName; this.lblTel.Text = model.Tel; this.lblMobil.Text = model.Mobil; this.lblAddress.Text = model.Address; this.lblPostCode.Text = model.PostCode; this.lblRemark.Text = model.Remark; this.lblState.Text = model.State.ToString(); this.lblAdminRemark.Text = model.AdminRemark; this.lblCreateTime.Text = model.CreateTime.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public DNSABC.Model.DNSABC_Invoice GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,UserID,InvoiceName,Price,PostType,RealName,Tel,Mobil,Address,PostCode,Remark,State,AdminRemark,CreateTime from DNSABC_Invoice "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; DNSABC.Model.DNSABC_Invoice model = new DNSABC.Model.DNSABC_Invoice(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["UserID"] != null && ds.Tables[0].Rows[0]["UserID"].ToString() != "") { model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString()); } if (ds.Tables[0].Rows[0]["InvoiceName"] != null && ds.Tables[0].Rows[0]["InvoiceName"].ToString() != "") { model.InvoiceName = ds.Tables[0].Rows[0]["InvoiceName"].ToString(); } if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = int.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if (ds.Tables[0].Rows[0]["PostType"] != null && ds.Tables[0].Rows[0]["PostType"].ToString() != "") { model.PostType = int.Parse(ds.Tables[0].Rows[0]["PostType"].ToString()); } if (ds.Tables[0].Rows[0]["RealName"] != null && ds.Tables[0].Rows[0]["RealName"].ToString() != "") { model.RealName = ds.Tables[0].Rows[0]["RealName"].ToString(); } if (ds.Tables[0].Rows[0]["Tel"] != null && ds.Tables[0].Rows[0]["Tel"].ToString() != "") { model.Tel = ds.Tables[0].Rows[0]["Tel"].ToString(); } if (ds.Tables[0].Rows[0]["Mobil"] != null && ds.Tables[0].Rows[0]["Mobil"].ToString() != "") { model.Mobil = ds.Tables[0].Rows[0]["Mobil"].ToString(); } if (ds.Tables[0].Rows[0]["Address"] != null && ds.Tables[0].Rows[0]["Address"].ToString() != "") { model.Address = ds.Tables[0].Rows[0]["Address"].ToString(); } if (ds.Tables[0].Rows[0]["PostCode"] != null && ds.Tables[0].Rows[0]["PostCode"].ToString() != "") { model.PostCode = ds.Tables[0].Rows[0]["PostCode"].ToString(); } if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "") { model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); } if (ds.Tables[0].Rows[0]["State"] != null && ds.Tables[0].Rows[0]["State"].ToString() != "") { model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString()); } if (ds.Tables[0].Rows[0]["AdminRemark"] != null && ds.Tables[0].Rows[0]["AdminRemark"].ToString() != "") { model.AdminRemark = ds.Tables[0].Rows[0]["AdminRemark"].ToString(); } if (ds.Tables[0].Rows[0]["CreateTime"] != null && ds.Tables[0].Rows[0]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DNSABC.Model.DNSABC_Invoice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update DNSABC_Invoice set "); strSql.Append("UserID=@UserID,"); strSql.Append("InvoiceName=@InvoiceName,"); strSql.Append("Price=@Price,"); strSql.Append("PostType=@PostType,"); strSql.Append("RealName=@RealName,"); strSql.Append("Tel=@Tel,"); strSql.Append("Mobil=@Mobil,"); strSql.Append("Address=@Address,"); strSql.Append("PostCode=@PostCode,"); strSql.Append("Remark=@Remark,"); strSql.Append("State=@State,"); strSql.Append("AdminRemark=@AdminRemark,"); strSql.Append("CreateTime=@CreateTime"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@InvoiceName", SqlDbType.VarChar, 200), new SqlParameter("@Price", SqlDbType.Int, 4), new SqlParameter("@PostType", SqlDbType.Int, 4), new SqlParameter("@RealName", SqlDbType.VarChar, 50), new SqlParameter("@Tel", SqlDbType.VarChar, 20), new SqlParameter("@Mobil", SqlDbType.VarChar, 20), new SqlParameter("@Address", SqlDbType.VarChar, 500), new SqlParameter("@PostCode", SqlDbType.VarChar, 20), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@AdminRemark", SqlDbType.VarChar, 500), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.UserID; parameters[1].Value = model.InvoiceName; parameters[2].Value = model.Price; parameters[3].Value = model.PostType; parameters[4].Value = model.RealName; parameters[5].Value = model.Tel; parameters[6].Value = model.Mobil; parameters[7].Value = model.Address; parameters[8].Value = model.PostCode; parameters[9].Value = model.Remark; parameters[10].Value = model.State; parameters[11].Value = model.AdminRemark; parameters[12].Value = model.CreateTime; parameters[13].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtUserID.Text)) { strErr += "申领人格式错误!\\n"; } if (this.txtInvoiceName.Text.Trim().Length == 0) { strErr += "发票抬头不能为空!\\n"; } if (!PageValidate.IsNumber(txtPrice.Text)) { strErr += "申领金额格式错误!\\n"; } if (!PageValidate.IsNumber(txtPostType.Text)) { strErr += "邮寄方式格式错误!\\n"; } if (this.txtRealName.Text.Trim().Length == 0) { strErr += "联系人不能为空!\\n"; } if (this.txtTel.Text.Trim().Length == 0) { strErr += "电话不能为空!\\n"; } if (this.txtMobil.Text.Trim().Length == 0) { strErr += "手机不能为空!\\n"; } if (this.txtAddress.Text.Trim().Length == 0) { strErr += "邮寄地址不能为空!\\n"; } if (this.txtPostCode.Text.Trim().Length == 0) { strErr += "邮编不能为空!\\n"; } if (this.txtRemark.Text.Trim().Length == 0) { strErr += "备注 用户申请发票时的备注信息不能为空!\\n"; } if (!PageValidate.IsNumber(txtState.Text)) { strErr += "管理员处理状态 0为未处理格式错误!\\n"; } if (this.txtAdminRemark.Text.Trim().Length == 0) { strErr += "管理员备注 备注发票邮寄方式信不能为空!\\n"; } if (!PageValidate.IsDateTime(txtCreateTime.Text)) { strErr += "创建时间格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int UserID = int.Parse(this.txtUserID.Text); string InvoiceName = this.txtInvoiceName.Text; int Price = int.Parse(this.txtPrice.Text); int PostType = int.Parse(this.txtPostType.Text); string RealName = this.txtRealName.Text; string Tel = this.txtTel.Text; string Mobil = this.txtMobil.Text; string Address = this.txtAddress.Text; string PostCode = this.txtPostCode.Text; string Remark = this.txtRemark.Text; int State = int.Parse(this.txtState.Text); string AdminRemark = this.txtAdminRemark.Text; DateTime CreateTime = DateTime.Parse(this.txtCreateTime.Text); DNSABC.Model.DNSABC_Invoice model = new DNSABC.Model.DNSABC_Invoice(); model.UserID = UserID; model.InvoiceName = InvoiceName; model.Price = Price; model.PostType = PostType; model.RealName = RealName; model.Tel = Tel; model.Mobil = Mobil; model.Address = Address; model.PostCode = PostCode; model.Remark = Remark; model.State = State; model.AdminRemark = AdminRemark; model.CreateTime = CreateTime; DNSABC.BLL.DNSABC_Invoice bll = new DNSABC.BLL.DNSABC_Invoice(); bll.Add(model); ROYcms.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }