123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- 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<PurPlanDT> 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<PurPlanDT> feedbacks = new List<PurPlanDT>();
- List<List<Object>> parametersContact = new List<List<Object>>();
- if (PushFeedbackId != null)
- {
- parametersContact.Add(new List<Object>() { "PushFeedbackId",PushFeedbackId });
- parametersContact.Add(new List<Object>() { "BillNo", BillNo });
- DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
- }
- if(dt!=null && dt.Rows.Count > 0)
- {
- feedbacks = (List<PurPlanDT>)ModelConvertHelper<PurPlanDT>.ConvertToModel(dt);
- }
- #endregion
- return feedbacks;
- }
-
- public static List<PurPlanMT> 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<PurPlanMT> feedbacks = new List<PurPlanMT>(0);
- List<List<Object>> parametersContact = new List<List<Object>>();
- if (PushRecordId != null)
- {
- //parametersContact.Add(new List<Object>() { "PushFeedbackId", Guid.Parse(PushFeedbackId) });
- parametersContact.Add(new List<Object>() { "PushRecordId", Guid.Parse(PushRecordId) });
- parametersContact.Add(new List<Object>() { "PushAccountId", PushAccountId });
- parametersContact.Add(new List<Object>() { "SuppliersId", SuppliersId });
- DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
- }
- if (dt != null && dt.Rows.Count > 0)
- {
- feedbacks = (List<PurPlanMT>)ModelConvertHelper<PurPlanMT>.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<List<Object>> parametersFeed = new List<List<Object>>();
- parametersFeed.Add(new List<Object>() { "RecordId", Guid.Parse(RecordId) });
- parametersFeed.Add(new List<Object>() { "IsComplete", 1 });
- parametersFeed.Add(new List<Object>() { "ConfirmPuchaseTime", DateTime.Now });
- parametersFeed.Add(new List<Object>() { "ConfirmPuchaser", accountid });
- List<SqlParameter> 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<List<Object>> parametersFeed = new List<List<Object>>();
- //parametersFeed.Add(new List<Object>() { "RecordId", RecordId });
- //parametersFeed.Add(new List<Object>() { "IsComplete", 1 });
- //parametersFeed.Add(new List<Object>() { "ConfirmPuchaseTime", DateTime.Now });
- //parametersFeed.Add(new List<Object>() { "ConfirmPuchaser", accountid });
- //List<SqlParameter> 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<List<Object>> parametersRecord = new List<List<Object>>();
- parametersRecord.Add(new List<Object>() { "FeedbackId", Guid.Parse(FeedbackId) });
- parametersRecord.Add(new List<Object>() { "IsComplete", 1 });
- parametersRecord.Add(new List<Object>() { "ConfirmPuchaseTime", DateTime.Now });
- parametersRecord.Add(new List<Object>() { "ConfirmPuchaser", accountid });
- List<SqlParameter> 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<DataAccessCommand> 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<List<Object>> parametersRecord = new List<List<Object>>();
- parametersRecord.Add(new List<Object>() { "RecordId", RecordId });
- parametersRecord.Add(new List<Object>() { "SuppliersId", SuppliersId });
- parametersRecord.Add(new List<Object>() { "BillState", 1 });
- parametersRecord.Add(new List<Object>() { "PurObj", PushAccountId });
- List<SqlParameter> 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;
- }
- }
- }
- }
|