/// <summary> /// 增加一条数据 /// </summary> public int Add(Hownet.Model.Product2DepotInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Product2DepotInfo("); strSql.Append("MainID,MaterielID,ColorID,ColorOneID,ColorTwoID,SizeID,BrandID,MListID,Remark,TaskID,DeparmentID,Amount,Price,Money,Weight,DepotInfoID)"); strSql.Append(" values ("); strSql.Append("@MainID,@MaterielID,@ColorID,@ColorOneID,@ColorTwoID,@SizeID,@BrandID,@MListID,@Remark,@TaskID,@DeparmentID,@Amount,@Price,@Money,@Weight,@DepotInfoID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MainID", SqlDbType.Int, 4), new SqlParameter("@MaterielID", SqlDbType.Int, 4), new SqlParameter("@ColorID", SqlDbType.Int, 4), new SqlParameter("@ColorOneID", SqlDbType.Int, 4), new SqlParameter("@ColorTwoID", SqlDbType.Int, 4), new SqlParameter("@SizeID", SqlDbType.Int, 4), new SqlParameter("@BrandID", SqlDbType.Int, 4), new SqlParameter("@MListID", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.NVarChar, 500), new SqlParameter("@TaskID", SqlDbType.Int, 4), new SqlParameter("@DeparmentID", SqlDbType.Int, 4), new SqlParameter("@Amount", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@Money", SqlDbType.Decimal, 9), new SqlParameter("@Weight", SqlDbType.Decimal, 9), new SqlParameter("@DepotInfoID", SqlDbType.Int, 4) }; parameters[0].Value = model.MainID; parameters[1].Value = model.MaterielID; parameters[2].Value = model.ColorID; parameters[3].Value = model.ColorOneID; parameters[4].Value = model.ColorTwoID; parameters[5].Value = model.SizeID; parameters[6].Value = model.BrandID; parameters[7].Value = model.MListID; parameters[8].Value = model.Remark; parameters[9].Value = model.TaskID; parameters[10].Value = model.DeparmentID; parameters[11].Value = model.Amount; parameters[12].Value = model.Price; parameters[13].Value = model.Money; parameters[14].Value = model.Weight; parameters[15].Value = model.DepotInfoID; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 入库处理 /// </summary> /// <param name="Amount">入库数量,工序全部完成自动入库时,设置为-1</param> /// <param name="NID">机器号</param> public static string InDepotAmount(int Amount, int NID, int _depotID) { Hownet.BLL.Product2Depot bllP2D = new Hownet.BLL.Product2Depot(); Hownet.Model.Product2Depot modP2D = new Hownet.Model.Product2Depot(); Hownet.BLL.Product2DepotInfo bllP2DInfo = new Hownet.BLL.Product2DepotInfo(); Hownet.Model.Product2DepotInfo modP2DInfo = new Hownet.Model.Product2DepotInfo(); Hownet.BLL.Repertory bllRep = new Hownet.BLL.Repertory(); Hownet.Model.Repertory modRep = new Hownet.Model.Repertory(); Hownet.BLL.AmountInfo bllAI = new Hownet.BLL.AmountInfo(); DataRow[] drsMain = BasicTable.dtMain.Select("(No=" + NID + ")"); if (drsMain.Length == 0) { return(ReturnStr(0, NID, "无相关记录")); } bool t = false; Hownet.BLL.WorkTicket bllWT = new Hownet.BLL.WorkTicket();//有当前卡机的刷卡记录,读出相应分箱记录 DataTable dttWT = bllWT.GetInDepotList(Convert.ToInt32(drsMain[0]["TicketID"])).Tables[0]; List <Hownet.Model.WorkTicket> liWT = bllWT.DataTableToList(dttWT); if (liWT[0].P2DInfoID > 0 && Amount == -1) { return(ReturnStr(0, NID, "本箱已入库")); } //if (Amount == -1) //{ //} #region 记入入库明细 DataTable dtP2D = new DataTable(); if (Amount == -1) { dtP2D = bllP2D.GetList("(DateTime='" + DateTime.Today + "') And (IsVerify=4) And (DepotID=" + _depotID + ")").Tables[0]; if (dtP2D.Rows.Count == 0)//查出当天已审核的该仓库入库表 { modP2D = new Hownet.Model.Product2Depot(); modP2D.DateTime = DateTime.Today; modP2D.Num = bllP2D.NewNum(modP2D.DateTime); modP2D.DepotID = _depotID; modP2D.IsVerify = 4; modP2D.VerifyMan = 0; modP2D.VerifyDate = modP2D.DateTime; modP2D.UpData = 1; modP2D.A = 1; modP2D.TypeID = 8; modP2D.Remark = ""; modP2D.ID = bllP2D.Add(modP2D); dtP2D = bllP2D.GetList("(ID=" + modP2D.ID + ")").Tables[0]; } } if (liWT[0].P2DInfoID > 0)//这箱货已有入库单编号 { modP2DInfo = bllP2DInfo.GetModel(liWT[0].P2DInfoID); if (Amount == -1) { if (modP2DInfo.MainID == Convert.ToInt32(dtP2D.Rows[0]["ID"]))//这个入库单明细的主表,等于今天的自动入库单编号 { Amount = Convert.ToInt32(drsMain[0]["Amount"]); modP2DInfo.Amount = modP2DInfo.Amount - liWT[0].EligibleAmount + Amount;//更新入库数量 bllP2DInfo.Update(modP2DInfo); t = true; } else { return(ReturnStr(0, NID, "已于此前入库")); } } else { modP2DInfo.Amount = modP2DInfo.Amount - liWT[0].EligibleAmount + Amount;//更新入库数量 bllP2DInfo.Update(modP2DInfo); t = true; } } else { if (Amount == -1) { Amount = Convert.ToInt32(drsMain[0]["Amount"]); } modP2DInfo = new Hownet.Model.Product2DepotInfo(); modP2DInfo.A = modP2DInfo.ID = 0; modP2DInfo.MainID = Convert.ToInt32(dtP2D.Rows[0]["ID"]); modP2DInfo.MaterielID = Convert.ToInt32(drsMain[0]["MaterielID"]); modP2DInfo.ColorID = liWT[0].ColorID; modP2DInfo.ColorOneID = liWT[0].ColorOneID; modP2DInfo.ColorTwoID = liWT[0].ColorTwoID; modP2DInfo.DeparmentID = liWT[0].DepartmentID; modP2DInfo.SizeID = liWT[0].SizeID; modP2DInfo.BrandID = liWT[0].BrandID; modP2DInfo.Remark = ""; modP2DInfo.TaskID = liWT[0].TaskID; modP2DInfo.Amount = Amount; if (liWT[0].MListID > 0) { modP2DInfo.MListID = liWT[0].MListID; } else { Hownet.BLL.MaterielList bllML = new Hownet.BLL.MaterielList(); Hownet.Model.MaterielList modML = new Hownet.Model.MaterielList(); modML.A = 1; } liWT[0].P2DInfoID = modP2DInfo.ID = bllP2DInfo.Add(modP2DInfo); } #endregion #region 更新库存 try { DataTable dtRep = bllRep.GetList("(DepartmentID=" + _depotID + ") And (MListID=" + liWT[0].MListID + ")").Tables[0]; if (dtRep.Rows.Count > 0) { modRep = bllRep.GetModel(Convert.ToInt32(dtRep.Rows[0]["ID"])); if (Amount == -1) { modRep.Amount += liWT[0].Amount; } else { if (t) { modRep.Amount = modRep.Amount - liWT[0].EligibleAmount + Amount; } else { modRep.Amount += Amount; } } bllRep.Update(modRep); } else { Hownet.BLL.Materiel bllMat = new Hownet.BLL.Materiel(); modRep = new Hownet.Model.Repertory(); modRep.ID = modRep.A = 0; modRep.MListID = liWT[0].MListID; modRep.MeasureID = bllMat.GetModel(Convert.ToInt32(drsMain[0]["MaterielID"])).MeasureID; modRep.ColorID = liWT[0].ColorID; modRep.ColorOneID = liWT[0].ColorOneID; modRep.ColorTwoID = liWT[0].ColorTwoID; modRep.SizeID = liWT[0].SizeID; modRep.BrandID = liWT[0].BrandID; modRep.CompanyID = 0; modRep.DepartmentID = _depotID; modRep.Amount = Amount; modRep.MaterielID = Convert.ToInt32(drsMain[0]["MaterielID"]); bllRep.Add(modRep); } #endregion #region 更总生产单在线数量 List <Hownet.Model.AmountInfo> liAI = bllAI.GetModelList("(MainID=" + liWT[0].TaskID + ") And (TableTypeID=1) And (MListID=" + liWT[0].MListID + ")"); if (liAI.Count > 0) { if (Amount == -1) { liAI[0].NotAmount -= liWT[0].Amount; } else { if (t) { liAI[0].NotAmount = liAI[0].NotAmount + liWT[0].EligibleAmount - Amount; } else { liAI[0].NotAmount -= Amount; } } bllAI.Update(liAI[0]); } if (liWT[0].TaskID > 0) { liAI = bllAI.GetModelList("(MainID=" + liWT[0].DepartmentID + ") And (TableTypeID=37) And (MListID=" + liWT[0].MListID + ")"); if (liAI.Count > 0) { if (Amount == -1) { liAI[0].NotAmount -= liWT[0].Amount; } else { if (t) { liAI[0].NotAmount = liAI[0].NotAmount + liWT[0].EligibleAmount - Amount; } else { liAI[0].NotAmount -= Amount; } } bllAI.Update(liAI[0]); } } #endregion #region 更新分箱表 liWT[0].EligibleAmount = Amount; liWT[0].InferiorAmount = liWT[0].Amount - Amount; liWT[0].P2DInfoID = modP2DInfo.ID; liWT[0].P2DDepartmentID = _depotID; bllWT.Update(liWT[0]); #endregion if (Amount > 0 && t) { for (int i = 0; i < drsMain.Length; i++) { drsMain[i].Delete(); } BasicTable.dtMain.AcceptChanges(); } DataTable dtttt = bllP2D.GetSumAmount(DateTime.Today, modP2DInfo.DeparmentID).Tables[0]; string ttt = string.Empty; if (dtttt.Rows.Count > 0) { ttt = dtttt.Rows[0]["Name"].ToString(); } int l = 15 - gb.GetByteCount(ttt); if (l > 0) { for (int i = 0; i < l; i++) { ttt = ttt + " "; } } ttt += dtttt.Rows[0]["Amount"].ToString(); return(ReturnStr(0, NID, ttt)); } catch (Exception ex) { return(ReturnStr(0, NID, "错误")); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hownet.Model.Product2DepotInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Product2DepotInfo set "); strSql.Append("MainID=@MainID,"); strSql.Append("MaterielID=@MaterielID,"); strSql.Append("ColorID=@ColorID,"); strSql.Append("ColorOneID=@ColorOneID,"); strSql.Append("ColorTwoID=@ColorTwoID,"); strSql.Append("SizeID=@SizeID,"); strSql.Append("BrandID=@BrandID,"); strSql.Append("MListID=@MListID,"); strSql.Append("Remark=@Remark,"); strSql.Append("TaskID=@TaskID,"); strSql.Append("DeparmentID=@DeparmentID,"); strSql.Append("Amount=@Amount,"); strSql.Append("Price=@Price,"); strSql.Append("Money=@Money,"); strSql.Append("Weight=@Weight,"); strSql.Append("DepotInfoID=@DepotInfoID"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@MainID", SqlDbType.Int, 4), new SqlParameter("@MaterielID", SqlDbType.Int, 4), new SqlParameter("@ColorID", SqlDbType.Int, 4), new SqlParameter("@ColorOneID", SqlDbType.Int, 4), new SqlParameter("@ColorTwoID", SqlDbType.Int, 4), new SqlParameter("@SizeID", SqlDbType.Int, 4), new SqlParameter("@BrandID", SqlDbType.Int, 4), new SqlParameter("@MListID", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.NVarChar, 500), new SqlParameter("@TaskID", SqlDbType.Int, 4), new SqlParameter("@DeparmentID", SqlDbType.Int, 4), new SqlParameter("@Amount", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@Money", SqlDbType.Decimal, 9), new SqlParameter("@Weight", SqlDbType.Decimal, 9), new SqlParameter("@DepotInfoID", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.MainID; parameters[1].Value = model.MaterielID; parameters[2].Value = model.ColorID; parameters[3].Value = model.ColorOneID; parameters[4].Value = model.ColorTwoID; parameters[5].Value = model.SizeID; parameters[6].Value = model.BrandID; parameters[7].Value = model.MListID; parameters[8].Value = model.Remark; parameters[9].Value = model.TaskID; parameters[10].Value = model.DeparmentID; parameters[11].Value = model.Amount; parameters[12].Value = model.Price; parameters[13].Value = model.Money; parameters[14].Value = model.Weight; parameters[15].Value = model.DepotInfoID; parameters[16].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Hownet.Model.Product2DepotInfo GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,MainID,MaterielID,ColorID,ColorOneID,ColorTwoID,SizeID,BrandID,MListID,Remark,TaskID,DeparmentID,Amount,Price,Money,Weight,DepotInfoID from Product2DepotInfo "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Hownet.Model.Product2DepotInfo model = new Hownet.Model.Product2DepotInfo(); 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]["MainID"] != null && ds.Tables[0].Rows[0]["MainID"].ToString() != "") { model.MainID = int.Parse(ds.Tables[0].Rows[0]["MainID"].ToString()); } if (ds.Tables[0].Rows[0]["MaterielID"] != null && ds.Tables[0].Rows[0]["MaterielID"].ToString() != "") { model.MaterielID = int.Parse(ds.Tables[0].Rows[0]["MaterielID"].ToString()); } if (ds.Tables[0].Rows[0]["ColorID"] != null && ds.Tables[0].Rows[0]["ColorID"].ToString() != "") { model.ColorID = int.Parse(ds.Tables[0].Rows[0]["ColorID"].ToString()); } if (ds.Tables[0].Rows[0]["ColorOneID"] != null && ds.Tables[0].Rows[0]["ColorOneID"].ToString() != "") { model.ColorOneID = int.Parse(ds.Tables[0].Rows[0]["ColorOneID"].ToString()); } if (ds.Tables[0].Rows[0]["ColorTwoID"] != null && ds.Tables[0].Rows[0]["ColorTwoID"].ToString() != "") { model.ColorTwoID = int.Parse(ds.Tables[0].Rows[0]["ColorTwoID"].ToString()); } if (ds.Tables[0].Rows[0]["SizeID"] != null && ds.Tables[0].Rows[0]["SizeID"].ToString() != "") { model.SizeID = int.Parse(ds.Tables[0].Rows[0]["SizeID"].ToString()); } if (ds.Tables[0].Rows[0]["BrandID"] != null && ds.Tables[0].Rows[0]["BrandID"].ToString() != "") { model.BrandID = int.Parse(ds.Tables[0].Rows[0]["BrandID"].ToString()); } if (ds.Tables[0].Rows[0]["MListID"] != null && ds.Tables[0].Rows[0]["MListID"].ToString() != "") { model.MListID = int.Parse(ds.Tables[0].Rows[0]["MListID"].ToString()); } model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); if (ds.Tables[0].Rows[0]["TaskID"] != null && ds.Tables[0].Rows[0]["TaskID"].ToString() != "") { model.TaskID = int.Parse(ds.Tables[0].Rows[0]["TaskID"].ToString()); } if (ds.Tables[0].Rows[0]["DeparmentID"] != null && ds.Tables[0].Rows[0]["DeparmentID"].ToString() != "") { model.DeparmentID = int.Parse(ds.Tables[0].Rows[0]["DeparmentID"].ToString()); } if (ds.Tables[0].Rows[0]["Amount"] != null && ds.Tables[0].Rows[0]["Amount"].ToString() != "") { model.Amount = int.Parse(ds.Tables[0].Rows[0]["Amount"].ToString()); } if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if (ds.Tables[0].Rows[0]["Money"] != null && ds.Tables[0].Rows[0]["Money"].ToString() != "") { model.Money = decimal.Parse(ds.Tables[0].Rows[0]["Money"].ToString()); } if (ds.Tables[0].Rows[0]["Weight"] != null && ds.Tables[0].Rows[0]["Weight"].ToString() != "") { model.Weight = decimal.Parse(ds.Tables[0].Rows[0]["Weight"].ToString()); } if (ds.Tables[0].Rows[0]["DepotInfoID"] != null && ds.Tables[0].Rows[0]["DepotInfoID"].ToString() != "") { model.DepotInfoID = int.Parse(ds.Tables[0].Rows[0]["DepotInfoID"].ToString()); } model.A = 1; return(model); } else { return(null); } }