public static bool ConfirmBill(StorageLossModel model) { ArrayList lstConfirm = new ArrayList(); StringBuilder sql = new StringBuilder(); sql.AppendLine(" UPDATE officedba.StorageLoss 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<StorageLossDetailModel> modelList = new List<StorageLossDetailModel>(); string sqlSele = "select ProductID,BatchNo,LossNo,UnitPrice,CompanyCD,UsedUnitCount,ProductCount from officedba.StorageLossDetail where CompanyCD='" + model.CompanyCD + "'" + "and LossNo=(select LossNo from officedba.StorageLoss where ID=" + model.ID + ")"; DataTable dt = SqlHelper.ExecuteSql(sqlSele); string sqlpri = "select StorageID from officedba.StorageLoss where ID=" + model.ID + ""; DataTable dt1 = SqlHelper.ExecuteSql(sqlpri); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { StorageLossDetailModel modelDetail = new StorageLossDetailModel(); if (dt.Rows[i]["ProductID"].ToString() != "") { modelDetail.ProductID = dt.Rows[i]["ProductID"].ToString(); } if (dt.Rows[i]["ProductCount"].ToString() != "") { modelDetail.ProductCount = dt.Rows[i]["ProductCount"].ToString(); } modelDetail.BatchNo = dt.Rows[i]["BatchNo"].ToString(); if (dt.Rows[i]["UsedUnitCount"].ToString() == "") modelDetail.UsedUnitCount = dt.Rows[i]["ProductCount"].ToString(); else modelDetail.UsedUnitCount = dt.Rows[i]["UsedUnitCount"].ToString(); modelList.Add(modelDetail); #region 操作库存流水账 StorageAccountModel AccountM_ = new StorageAccountModel(); AccountM_.BatchNo = dt.Rows[i]["BatchNo"].ToString(); AccountM_.BillNo = dt.Rows[i]["LossNo"].ToString(); AccountM_.BillType = 16; AccountM_.CompanyCD = dt.Rows[i]["CompanyCD"].ToString(); AccountM_.Creator = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).EmployeeID; AccountM_.HappenCount = Convert.ToDecimal(dt.Rows[i]["ProductCount"].ToString()); AccountM_.HappenDate = System.DateTime.Now; AccountM_.PageUrl = "../Office/StorageManager/StorageLossAdd.aspx"; AccountM_.Price = Convert.ToDecimal(dt.Rows[i]["UnitPrice"].ToString()); AccountM_.ProductCount = Convert.ToDecimal(dt.Rows[i]["ProductCount"].ToString()); AccountM_.ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"].ToString()); AccountM_.StorageID = Convert.ToInt32(dt1.Rows[0]["StorageID"].ToString()); SqlCommand AccountCom_ = StorageAccountDBHelper.InsertStorageAccountCommand(AccountM_,"1"); lstConfirm.Add(AccountCom_); #endregion } } if (modelList != null && modelList.Count > 0)//明细不为空的时候 { for (int i = 0; i < modelList.Count; i++) { SqlCommand commPD = updateStorageProduct(modelList[i].BatchNo, modelList[i].ProductID, model.StorageID, modelList[i].ProductCount, model, false); lstConfirm.Add(commPD); } } return SqlHelper.ExecuteTransWithArrayList(lstConfirm); }
public static bool CancelConfirmBill(StorageLossModel model) { ArrayList lstConfirm = new ArrayList(); StringBuilder sql = new StringBuilder(); sql.AppendLine(" UPDATE officedba.StorageLoss SET"); sql.AppendLine(" Confirmor = @Confirmor,"); sql.AppendLine(" confirmDate = getdate(),"); sql.AppendLine(" BillStatus = 1,"); 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<StorageLossDetailModel> modelList = new List<StorageLossDetailModel>(); string sqlSele = "select ProductID,BatchNo,UsedUnitCount,ProductCount from officedba.StorageLossDetail where CompanyCD='" + model.CompanyCD + "'" + "and LossNo=(select LossNo from officedba.StorageLoss 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++) { StorageLossDetailModel modelDetail = new StorageLossDetailModel(); if (dt.Rows[i]["ProductID"].ToString() != "") { modelDetail.ProductID = dt.Rows[i]["ProductID"].ToString(); } if (dt.Rows[i]["ProductCount"].ToString() != "") { modelDetail.ProductCount = dt.Rows[i]["ProductCount"].ToString(); } modelDetail.BatchNo = dt.Rows[i]["BatchNo"].ToString(); if (dt.Rows[i]["UsedUnitCount"].ToString() == "") modelDetail.UsedUnitCount = dt.Rows[i]["ProductCount"].ToString(); else modelDetail.UsedUnitCount = dt.Rows[i]["UsedUnitCount"].ToString(); modelList.Add(modelDetail); } } if (modelList != null && modelList.Count > 0)//明细不为空的时候 { for (int i = 0; i < modelList.Count; i++) { SqlCommand commPD = updateStorageProduct(modelList[i].BatchNo, modelList[i].ProductID, model.StorageID, modelList[i].ProductCount, model, true); lstConfirm.Add(commPD); } } //获取登陆用户信息 UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; //获取公司代码 string companyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; //撤销审批 string CompanyCD = userInfo.CompanyCD; string BillTypeFlag = ConstUtil.CODING_RULE_Storage_NO; string BillTypeCode = ConstUtil.CODING_RULE_StorageLoss_NO; string strUserID = userInfo.UserID; ; DataTable dt2 = FlowDBHelper.GetFlowInstanceInfo(CompanyCD, Convert.ToInt32(BillTypeFlag), Convert.ToInt32(BillTypeCode), Convert.ToInt32(model.ID)); if (dt.Rows.Count > 0) { string FlowInstanceID = dt2.Rows[0]["FlowInstanceID"].ToString(); string FlowStatus = dt2.Rows[0]["FlowStatus"].ToString(); string FlowNo = dt2.Rows[0]["FlowNo"].ToString(); lstConfirm.Add(FlowDBHelper.CancelConfirmHis(CompanyCD, FlowInstanceID, FlowNo, BillTypeFlag, BillTypeCode, strUserID)); lstConfirm.Add(FlowDBHelper.CancelConfirmTsk(CompanyCD, FlowInstanceID, strUserID)); lstConfirm.Add(FlowDBHelper.CancelConfirmIns(CompanyCD, FlowNo, BillTypeFlag, BillTypeCode, model.ID, strUserID)); } return SqlHelper.ExecuteTransWithArrayList(lstConfirm); }
/// <summary> /// 明细参数设置 /// </summary> /// <param name="comm"></param> /// <param name="model"></param> private static void EditLossDetailInfo(SqlCommand comm, StorageLossDetailModel model) { //@CompanyCD,@LossNo,@SortNo,@ProductID,@ProductCount,@UnitPrice,@CostPrice,@Remark) comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD ", model.CompanyCD));//公司代码 comm.Parameters.Add(SqlHelper.GetParameterFromString("@LossNo ", model.LossNo));//报损单编号 comm.Parameters.Add(SqlHelper.GetParameterFromString("@SortNo ", model.SortNo));// comm.Parameters.Add(SqlHelper.GetParameterFromString("@ProductID ", model.ProductID));//物品ID comm.Parameters.Add(SqlHelper.GetParameterFromString("@UnitPrice ", model.UnitPrice));//报损单价(基本单价) comm.Parameters.Add(SqlHelper.GetParameterFromString("@ProductCount ", model.ProductCount));//报损数量(基本数量) comm.Parameters.Add(SqlHelper.GetParameterFromString("@CostPrice ", model.CostPrice));//报损金额 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Remark ", model.Remark));//备注 comm.Parameters.Add(SqlHelper.GetParameterFromString("@UnitID ", model.UnitID));//基本单位 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));//批次 }