/// <summary> /// 查询添加成功的表单查询 /// </summary> /// <returns></returns> public static List <SaveIntoDetail> CheckGridView(string AppendID) { Database db = DatabaseFactory.CreateDatabase("Constr"); string sql = string.Format(@"select t_AppendStockDetail.DetailID,ps.ProductsID,ProductsName,SupplierName,Quantity,Price,Price*Quantity Total from t_AppendStockDetail join (select p.ProductsID,p.ProductsName,p.SupplierID,t_Supplier.SupplierName from t_Supplier join (select distinct p.ProductsID,p.ProductsName,s.SupplierID from t_AppendStockDetail s join t_Products p on s.ProductsID=p.ProductsID ) p on t_Supplier.SupplierID=p.SupplierID) ps on t_AppendStockDetail.ProductsID=ps.ProductsID and ps.SupplierID=t_AppendStockDetail.SupplierID and t_AppendStockDetail.AppendID ='{0}'", AppendID); DataSet ds = db.ExecuteDataSet(CommandType.Text, sql); List <SaveIntoDetail> list = new List <SaveIntoDetail>(); foreach (DataRow item in ds.Tables[0].Rows) { SaveIntoDetail s = new SaveIntoDetail(); s.DetailID = int.Parse(item["DetailID"].ToString()); s.ProductsID = int.Parse(item["ProductsID"].ToString()); s.ProductsName = item["ProductsName"].ToString(); s.SupplierName = item["SupplierName"].ToString(); s.Quantity = int.Parse(item["Quantity"].ToString()); s.Price = Convert.ToDouble(item["Price"].ToString()); s.Total = Convert.ToDouble(item["Total"].ToString()); list.Add(s); } return(list); }
/// <summary> /// 添加编辑的信息到保存表里 /// </summary> /// <param name="supplyname"></param> /// <returns></returns> public static bool AddMessage(SaveIntoDetail save) { Database db = DatabaseFactory.CreateDatabase("Constr"); string sql = string.Format(@"insert into t_AppendStockDetail values('{0}',{1},{2},{3},{4},'{5}')", save.AppendID, save.ProductsID, save.SupplierID, save.Quantity, save.Price, save.Description == "" ? " " : save.Description); return(db.ExecuteNonQuery(CommandType.Text, sql) > 0); }
//点击保存 保存信息 protected void btnSave_Click(object sender, EventArgs e) { SaveIntoDetail save = new SaveIntoDetail(); save.AppendID = this.txtOrderID.Text; save.ProductsID = int.Parse(this.ProID.Text); save.ProductsName = this.txtPro.Text; save.SupplierID = BLL.PIntoBLL.ProIntoManager.GetSupplierID(this.txtSupply.Text); save.Quantity = int.Parse(this.txtCount.Text); save.Price = Convert.ToDouble(this.txtPrice.Text); save.Total = Convert.ToDouble(this.txtPrice.Text) * int.Parse(this.txtCount.Text); if (BLL.PIntoBLL.ProIntoManager.AddMessage(save)) { this.GridViewMessage.DataSource = BLL.PIntoBLL.ProIntoManager.CheckGridView(save.AppendID); this.GridViewMessage.DataBind(); } else { Response.Write("<script>alert('添加信息失败')</script>"); } }
//添加信息保存到数据库 public static bool AddMessage(SaveIntoDetail save) { return(DAL.PIntoDAL.ProIntoService.AddMessage(save)); }