using Common.Model; using Common.Wechat; using CoreEntity.Entity; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Text; using ZcPeng.PublicLibrary; namespace CoreEntity.DAL { public class PurPlanDAL { public static List GetPlanDT(int BillNo,string PushFeedbackId) { #region 获取 plan string commandTextContact = "Select * From PurPlanDT " + "Where PushFeedbackId = @PushFeedbackId " + " and BillNo = @BillNo"; string resultContact; DataTable dt = new DataTable(); List feedbacks = new List(); List> parametersContact = new List>(); if (PushFeedbackId != null) { parametersContact.Add(new List() { "PushFeedbackId",PushFeedbackId }); parametersContact.Add(new List() { "BillNo", BillNo }); DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact); } if(dt!=null && dt.Rows.Count > 0) { feedbacks = (List)ModelConvertHelper.ConvertToModel(dt); } #endregion return feedbacks; } public static List GetPlanMT(string PushRecordId, string PushFeedbackId, Int32 PushAccountId,string SuppliersId) { #region 获取 plan string commandTextContact = "Select * From PurPlanMT " + " Where PushRecordId = @PushRecordId " + " and BillState = 0 " + " and PurObj = @PushAccountId" + " and SuppliersId = @SuppliersId " //+" and PushFeedBackId in ( select Id from " + Config.TablePrefix+ "PushFeedback B " + //" where 1= 1" + //" and state = 3 " + //" and B.Id = @PushFeedbackId " + //" and B.SuppliersId = @SuppliersId" + //") " ; string resultContact; DataTable dt = new DataTable(); List feedbacks = new List(0); List> parametersContact = new List>(); if (PushRecordId != null) { //parametersContact.Add(new List() { "PushFeedbackId", Guid.Parse(PushFeedbackId) }); parametersContact.Add(new List() { "PushRecordId", Guid.Parse(PushRecordId) }); parametersContact.Add(new List() { "PushAccountId", PushAccountId }); parametersContact.Add(new List() { "SuppliersId", SuppliersId }); DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact); } if (dt != null && dt.Rows.Count > 0) { feedbacks = (List)ModelConvertHelper.ConvertToModel(dt); } #endregion return feedbacks; } //IsComplete 1 public static int UpdateRecordPlanState(string RecordId, string LoginAccountId,out string resultState) { int accountid = Convert.ToInt32(LoginAccountId); #region 更新记录 string commandTextFeed = "UPDATE " + Config.TablePrefix + "PushRecord " + " SET IsComplete = @IsComplete, " + " ConfirmPuchaseTime = @ConfirmPuchaseTime," + " ConfirmPuchaser = @ConfirmPuchaser," + " State = 3 " + " WHERE Id= @RecordId AND (IsComplete IS NULL OR IsComplete = 0 ) "; string resultFeed; //准备参数 List> parametersFeed = new List>(); parametersFeed.Add(new List() { "RecordId", Guid.Parse(RecordId) }); parametersFeed.Add(new List() { "IsComplete", 1 }); parametersFeed.Add(new List() { "ConfirmPuchaseTime", DateTime.Now }); parametersFeed.Add(new List() { "ConfirmPuchaser", accountid }); List parametersFeed1 = DataAccess.ToParameters(parametersFeed); int successFeed = DataAccess.ExecuteCommand(commandTextFeed, parametersFeed1, out resultFeed); resultState = resultFeed; #endregion return successFeed; } //IsComplete 1 public static int UpdatePlanState(string FeedbackId,string RecordId,string LoginAccountId,out string result ,string fieldExt="") { int accountid = Convert.ToInt32(LoginAccountId); //#region 更新记录 //string commandTextFeed = "UPDATE " + Config.TablePrefix + "PushRecord " + // " SET IsComplete = @IsComplete, " + // " ConfirmPuchaseTime = @ConfirmPuchaseTime," + // " ConfirmPuchaser = @ConfirmPuchaser," + // " State = 3 " + // " WHERE Id= @RecordId AND (IsComplete = 0 ) "; //string resultFeed; ////准备参数 //List> parametersFeed = new List>(); //parametersFeed.Add(new List() { "RecordId", RecordId }); //parametersFeed.Add(new List() { "IsComplete", 1 }); //parametersFeed.Add(new List() { "ConfirmPuchaseTime", DateTime.Now }); //parametersFeed.Add(new List() { "ConfirmPuchaser", accountid }); //List parametersFeed1 = DataAccess.ToParameters(parametersFeed); //int successFeed = DataAccess.ExecuteCommand(commandTextFeed, parametersFeed1, out resultFeed); //#endregion #region 更新明细 string commandTextRecord = "UPDATE " + Config.TablePrefix + "PushFeedback " + " SET " + " IsComplete = @IsComplete, " + " ConfirmPuchaseTime = @ConfirmPuchaseTime," + " ConfirmPuchaser = @ConfirmPuchaser," + fieldExt+ " State = 3 " + " WHERE Id= @FeedbackId AND State in(1,2) "; string resultRecord; //准备参数 List> parametersRecord = new List>(); parametersRecord.Add(new List() { "FeedbackId", Guid.Parse(FeedbackId) }); parametersRecord.Add(new List() { "IsComplete", 1 }); parametersRecord.Add(new List() { "ConfirmPuchaseTime", DateTime.Now }); parametersRecord.Add(new List() { "ConfirmPuchaser", accountid }); List parametersRecord1 = DataAccess.ToParameters(parametersRecord); int successRecord = DataAccess.ExecuteCommand(commandTextRecord, parametersRecord1, out resultRecord); result = resultRecord; #endregion if ( successRecord > 0) return 1; else return 0; } //IsDelete 1 public static int UpdatePlanDelete(string SuppliersId, string RecordId,int PushAccountId,List listcmd = null) { #region 更新明细 string commandTextRecord = "UPDATE PurPlanMT " + " SET " + " BillState = @BillState " + " WHERE PushRecordId= @RecordId" + " and SuppliersId= @SuppliersId " + " AND (BillState = 0) " + " and PurObj = @PurObj " ; string resultRecord; //准备参数 List> parametersRecord = new List>(); parametersRecord.Add(new List() { "RecordId", RecordId }); parametersRecord.Add(new List() { "SuppliersId", SuppliersId }); parametersRecord.Add(new List() { "BillState", 1 }); parametersRecord.Add(new List() { "PurObj", PushAccountId }); List parametersRecord1 = DataAccess.ToParameters(parametersRecord); #endregion if(listcmd == null) { int successRecord = DataAccess.ExecuteCommand(commandTextRecord, parametersRecord1, out resultRecord); if (successRecord > 0) return 1; else return 0; } else { listcmd.Add(new DataAccessCommand(commandTextRecord, parametersRecord1,CommandType.Text,true)); return 1; } } } }