/// <summary> /// 明细参数设置 /// </summary> /// <param name="comm"></param> /// <param name="model"></param> private static void EditInitailDetailInfo(SqlCommand comm, StorageInitailDetailModel model) { //@InNo,@SortNo,@ProductID,@UnitPrice,@ProductCount,@TotalPrice,@Remark,getdate(),@ModifiedUserID,@CompanyCD comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD ", model.CompanyCD)); //公司代码 comm.Parameters.Add(SqlHelper.GetParameterFromString("@InNo ", model.InNo)); //入库单编号 comm.Parameters.Add(SqlHelper.GetParameterFromString("@ProductID ", model.ProductID)); //物品ID comm.Parameters.Add(SqlHelper.GetParameterFromString("@UnitPrice ", model.UnitPrice)); //入库单价 comm.Parameters.Add(SqlHelper.GetParameterFromString("@TotalPrice ", model.TotalPrice)); //入库单价 comm.Parameters.Add(SqlHelper.GetParameterFromString("@ProductCount ", model.ProductCount)); //入库数量 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Remark ", model.Remark)); //备注 comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID ", model.ModifiedUserID)); //最后更新用户ID(对应操作用户表中的UserID) comm.Parameters.Add(SqlHelper.GetParameterFromString("@SortNo ", model.SortNo)); // comm.Parameters.Add(SqlHelper.GetParameterFromString("@UsedUnitID ", model.UsedUnitID)); comm.Parameters.Add(SqlHelper.GetParameterFromString("@UsedUnitCount ", model.UsedUnitCount)); comm.Parameters.Add(SqlHelper.GetParameterFromString("@UsedPrice ", model.UsedPrice)); comm.Parameters.Add(SqlHelper.GetParameterFromString("@ExRate ", model.ExRate)); comm.Parameters.Add(SqlHelper.GetParameterFromString("@BatchNo ", model.BatchNo)); }
public static bool ConfirmBill(StorageInitailModel model) { ArrayList lstConfirm = new ArrayList(); StringBuilder sql = new StringBuilder(); sql.AppendLine(" UPDATE officedba.StorageInitail SET"); sql.AppendLine(" Confirmor = @Confirmor,"); sql.AppendLine(" confirmDate = getdate(),"); sql.AppendLine(" BillStatus = 2,"); sql.AppendLine(" ModifiedUserID = @ModifiedUserID,"); sql.AppendLine(" ModifiedDate = getdate()"); sql.AppendLine(" Where CompanyCD=@CompanyCD and ID=@ID"); SqlCommand comm = new SqlCommand(); comm.CommandText = sql.ToString(); comm.Parameters.Add(SqlHelper.GetParameterFromString("@Confirmor", model.Confirmor)); comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", model.ModifiedUserID)); comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD)); comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", model.ID)); lstConfirm.Add(comm); List <StorageInitailDetailModel> modelList = new List <StorageInitailDetailModel>(); string sqlSele = "select a.ID,a.CompanyCD, a.ProductID,b.StorageID,a.BatchNo,a.InNo BillNo,a.UnitPrice Price,Convert(varchar(10),b.EnterDate,23) HappenDate," + " a.Remark, a.ProductCount from officedba.StorageInitailDetail a left join" + " officedba.StorageInitail b on a.InNo=b.InNo and a.CompanyCD = b.CompanyCD where a.CompanyCD='" + model.CompanyCD + "' and a.InNo=(select InNo from officedba.StorageInitail where ID=" + model.ID + ")"; DataTable dt = SqlHelper.ExecuteSql(sqlSele); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { StorageInitailDetailModel modelDetail = new StorageInitailDetailModel(); StorageAccountModel StorageAccountM = new StorageAccountModel(); if (dt.Rows[i]["ProductID"].ToString() != "") { modelDetail.ProductID = dt.Rows[i]["ProductID"].ToString(); StorageAccountM.ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"].ToString()); } if (dt.Rows[i]["ProductCount"].ToString() != "") { modelDetail.ProductCount = dt.Rows[i]["ProductCount"].ToString(); StorageAccountM.HappenCount = Convert.ToDecimal(dt.Rows[i]["ProductCount"].ToString()); StorageAccountM.ProductCount = Convert.ToDecimal(dt.Rows[i]["ProductCount"].ToString()); } if (dt.Rows[i]["StorageID"].ToString() != "") { model.StorageID = dt.Rows[i]["StorageID"].ToString(); StorageAccountM.StorageID = Convert.ToInt32(dt.Rows[i]["StorageID"].ToString()); } //插入流水账表 StorageAccountM.CompanyCD = dt.Rows[i]["CompanyCD"].ToString(); StorageAccountM.BillType = 1; if (dt.Rows[i]["BatchNo"].ToString() != "") { modelDetail.BatchNo = dt.Rows[i]["BatchNo"].ToString(); StorageAccountM.BatchNo = dt.Rows[i]["BatchNo"].ToString(); } modelList.Add(modelDetail); StorageAccountM.BillNo = dt.Rows[i]["BillNo"].ToString(); StorageAccountM.Price = Convert.ToDecimal(dt.Rows[i]["Price"].ToString()); StorageAccountM.HappenDate = Convert.ToDateTime(dt.Rows[i]["HappenDate"].ToString()); StorageAccountM.Creator = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).EmployeeID; StorageAccountM.PageUrl = "../Office/StorageManager/StorageInitailAdd.aspx"; StorageAccountM.ReMark = dt.Rows[i]["Remark"].ToString(); SqlCommand commSA = new SqlCommand(); commSA = StorageAccountDBHelper.InsertStorageAccountCommand(StorageAccountM, "0"); lstConfirm.Add(commSA); } } if (modelList != null && modelList.Count > 0)//明细不为空的时候 { for (int i = 0; i < modelList.Count; i++) { SqlCommand commPD = new SqlCommand(); if (Exists(modelList[i].BatchNo, model.StorageID, modelList[i].ProductID, model.CompanyCD)) { commPD = updateStorageProduct(modelList[i].BatchNo, modelList[i].ProductID, model.StorageID, modelList[i].ProductCount, model, true); } else { commPD = InsertStorageProduct(modelList[i].BatchNo, modelList[i].ProductID, model.StorageID, modelList[i].ProductCount, model.CompanyCD); } lstConfirm.Add(commPD); } } return(SqlHelper.ExecuteTransWithArrayList(lstConfirm)); }