/// <summary> /// 删除询价单 /// </summary> /// <param name="APID"></param> /// <returns></returns> public bool Delete(string APID) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from AskPrice "); strSql.Append(" where APID=@APID "); SqlParameter[] parameters = { new SqlParameter("@APID", SqlDbType.VarChar, 36) }; parameters[0].Value = APID; int rows = 0; IDbTransaction transaction = DBAccess.BeginDbTransaction(DB.Type, DB.ConnectionString); try { //删除分录 AskPriceItemDAL item = new AskPriceItemDAL(); item.Delete(APID); //删除分阅人 APReaderDAL sor = new APReaderDAL(); sor.Delete(APID); //删除复核人 APSecondCheckDAL sos = new APSecondCheckDAL(); sos.Delete(APID); rows = DBAccess.ExecuteNonQuery(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters); transaction.Commit(); } catch { transaction.Rollback(); } if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddAskPrice(AskPrice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AskPrice("); strSql.Append("APID,APCode,AskDate,ClientName,ClientContact,ClientTel,ClientAddress,MaterialCode,MaterialName,Specs,Routing,PlanPrice,Issued,IssuedCount,ActualPrice,PayTypeID,TrackDescription,ClientSurvey,APRemark,Creator,CreateTime,Editor,EditTime,FirstChecker,State,SecondCheckerName,ReaderName,Qty,UnitID,IsTax,IsShipping)"); strSql.Append(" values ("); strSql.Append("@APID,@APCode,@AskDate,@ClientName,@ClientContact,@ClientTel,@ClientAddress,@MaterialCode,@MaterialName,@Specs,@Routing,@PlanPrice,@Issued,@IssuedCount,@ActualPrice,@PayTypeID,@TrackDescription,@ClientSurvey,@APRemark,@Creator,@CreateTime,@Editor,@EditTime,@FirstChecker,@State,@SecondCheckerName,@ReaderName,@Qty,@UnitID,@IsTax,@IsShipping)"); SqlParameter[] parameters = { new SqlParameter("@APID", SqlDbType.VarChar, 36), new SqlParameter("@APCode", SqlDbType.VarChar, 30), new SqlParameter("@AskDate", SqlDbType.Char, 8), new SqlParameter("@ClientName", SqlDbType.VarChar, 60), new SqlParameter("@ClientContact", SqlDbType.VarChar, 30), new SqlParameter("@ClientTel", SqlDbType.VarChar, 30), new SqlParameter("@ClientAddress", SqlDbType.VarChar, 90), new SqlParameter("@MaterialCode", SqlDbType.VarChar, 60), new SqlParameter("@MaterialName", SqlDbType.VarChar, 90), new SqlParameter("@Specs", SqlDbType.VarChar, 90), new SqlParameter("@Routing", SqlDbType.VarChar, 1024), new SqlParameter("@PlanPrice", SqlDbType.Decimal, 9), new SqlParameter("@Issued", SqlDbType.Char, 1), new SqlParameter("@IssuedCount", SqlDbType.Int, 4), new SqlParameter("@ActualPrice", SqlDbType.Decimal, 9), new SqlParameter("@PayTypeID", SqlDbType.VarChar, 36), new SqlParameter("@TrackDescription", SqlDbType.VarChar, 1024), new SqlParameter("@ClientSurvey", SqlDbType.VarChar, 1024), new SqlParameter("@APRemark", SqlDbType.VarChar, 1024), new SqlParameter("@Creator", SqlDbType.VarChar, 36), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Editor", SqlDbType.VarChar, 36), new SqlParameter("@EditTime", SqlDbType.DateTime), new SqlParameter("@FirstChecker", SqlDbType.VarChar, 36), new SqlParameter("@State", SqlDbType.Char, 1), new SqlParameter("@SecondCheckerName", SqlDbType.VarChar, 255), new SqlParameter("@ReaderName", SqlDbType.VarChar, 255), new SqlParameter("@Qty", SqlDbType.Decimal, 9), new SqlParameter("@UnitID", SqlDbType.VarChar, 36), new SqlParameter("@IsTax", SqlDbType.Char, 1), new SqlParameter("@IsShipping", SqlDbType.Char, 1) }; parameters[0].Value = model.APID; parameters[1].Value = model.APCode; if (string.IsNullOrEmpty(model.APCode)) { parameters[1].Value = "XJ" + System.DateTime.Now.Year + System.DateTime.Now.Month + System.DateTime.Now.Day + System.DateTime.Now.Hour + System.DateTime.Now.Minute + System.DateTime.Now.Second + System.DateTime.Now.Millisecond; } parameters[2].Value = model.AskDate; parameters[3].Value = model.ClientName; parameters[4].Value = model.ClientContact; parameters[5].Value = model.ClientTel; parameters[6].Value = model.ClientAddress; parameters[7].Value = model.MaterialCode; parameters[8].Value = model.MaterialName; parameters[9].Value = model.Specs; parameters[10].Value = model.Routing; parameters[11].Value = model.PlanPrice; parameters[12].Value = model.Issued; parameters[13].Value = model.IssuedCount; parameters[14].Value = model.ActualPrice; parameters[15].Value = model.PayTypeID; parameters[16].Value = model.TrackDescription; parameters[17].Value = model.ClientSurvey; parameters[18].Value = model.APRemark; parameters[19].Value = model.Creator; parameters[20].Value = model.CreateTime; parameters[21].Value = model.Editor; parameters[22].Value = model.EditTime; parameters[23].Value = model.FirstChecker; parameters[24].Value = model.State; parameters[25].Value = model.SecondCheckerName; parameters[26].Value = model.ReaderName; parameters[27].Value = model.Qty; parameters[28].Value = model.UnitID; parameters[29].Value = model.IsTax; parameters[30].Value = model.IsShipping; IDbTransaction transaction = DBAccess.BeginDbTransaction(DB.Type, DB.ConnectionString); try { DBAccess.ExecuteNonQuery(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters); APSecondCheckDAL apSC = new APSecondCheckDAL(); int socount = model.SCList.Count; if (socount > 0) { for (int i = 0; i < socount; i++) { APSecondCheck apsc = model.SCList[i] as APSecondCheck; apSC.Add(apsc); } } APReaderDAL apR = new APReaderDAL(); int rcount = model.RList.Count; if (rcount > 0) { for (int i = 0; i < rcount; i++) { APReader sor = model.RList[i] as APReader; apR.Add(sor); } } transaction.Commit(); } catch { transaction.Rollback(); } return(1); }
/// <summary> /// 修改询价单 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateAskPrice(AskPrice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AskPrice set "); strSql.Append("APCode=@APCode,"); strSql.Append("AskDate=@AskDate,"); strSql.Append("ClientName=@ClientName,"); strSql.Append("ClientContact=@ClientContact,"); strSql.Append("ClientTel=@ClientTel,"); strSql.Append("ClientAddress=@ClientAddress,"); strSql.Append("MaterialCode=@MaterialCode,"); strSql.Append("MaterialName=@MaterialName,"); strSql.Append("Specs=@Specs,"); strSql.Append("Routing=@Routing,"); strSql.Append("PlanPrice=@PlanPrice,"); strSql.Append("Issued=@Issued,"); strSql.Append("IssuedCount=@IssuedCount,"); strSql.Append("ActualPrice=@ActualPrice,"); strSql.Append("PayTypeID=@PayTypeID,"); strSql.Append("TrackDescription=@TrackDescription,"); strSql.Append("ClientSurvey=@ClientSurvey,"); strSql.Append("APRemark=@APRemark,"); strSql.Append("Creator=@Creator,"); strSql.Append("Editor=@Editor,"); strSql.Append("EditTime=@EditTime,"); strSql.Append("FirstChecker=@FirstChecker,"); strSql.Append("State=@State,"); strSql.Append("SecondCheckerName=@SecondCheckerName,"); strSql.Append("ReaderName=@ReaderName,"); strSql.Append("Qty=@Qty,"); strSql.Append("UnitID=@UnitID,"); strSql.Append("IsTax=@IsTax,"); strSql.Append("IsShipping=@IsShipping"); strSql.Append(" where APID=@APID "); SqlParameter[] parameters = { new SqlParameter("@APCode", SqlDbType.VarChar, 30), new SqlParameter("@AskDate", SqlDbType.Char, 8), new SqlParameter("@ClientName", SqlDbType.VarChar, 60), new SqlParameter("@ClientContact", SqlDbType.VarChar, 30), new SqlParameter("@ClientTel", SqlDbType.VarChar, 30), new SqlParameter("@ClientAddress", SqlDbType.VarChar, 90), new SqlParameter("@MaterialCode", SqlDbType.VarChar, 60), new SqlParameter("@MaterialName", SqlDbType.VarChar, 90), new SqlParameter("@Specs", SqlDbType.VarChar, 90), new SqlParameter("@Routing", SqlDbType.VarChar, 1024), new SqlParameter("@PlanPrice", SqlDbType.Decimal, 9), new SqlParameter("@Issued", SqlDbType.Char, 1), new SqlParameter("@IssuedCount", SqlDbType.Int, 4), new SqlParameter("@ActualPrice", SqlDbType.Decimal, 9), new SqlParameter("@PayTypeID", SqlDbType.VarChar, 36), new SqlParameter("@TrackDescription", SqlDbType.VarChar, 1024), new SqlParameter("@ClientSurvey", SqlDbType.VarChar, 1024), new SqlParameter("@APRemark", SqlDbType.VarChar, 1024), new SqlParameter("@Creator", SqlDbType.VarChar, 36), new SqlParameter("@Editor", SqlDbType.VarChar, 36), new SqlParameter("@EditTime", SqlDbType.DateTime), new SqlParameter("@FirstChecker", SqlDbType.VarChar, 36), new SqlParameter("@State", SqlDbType.Char, 1), new SqlParameter("@SecondCheckerName", SqlDbType.VarChar, 255), new SqlParameter("@ReaderName", SqlDbType.VarChar, 255), new SqlParameter("@Qty", SqlDbType.Decimal, 9), new SqlParameter("@UnitID", SqlDbType.VarChar, 36), new SqlParameter("@IsTax", SqlDbType.Char, 1), new SqlParameter("@IsShipping", SqlDbType.Char, 1), new SqlParameter("@APID", SqlDbType.VarChar, 36) }; parameters[0].Value = model.APCode; parameters[1].Value = model.AskDate; parameters[2].Value = model.ClientName; parameters[3].Value = model.ClientContact; parameters[4].Value = model.ClientTel; parameters[5].Value = model.ClientAddress; parameters[6].Value = model.MaterialCode; parameters[7].Value = model.MaterialName; parameters[8].Value = model.Specs; parameters[9].Value = model.Routing; parameters[10].Value = model.PlanPrice; parameters[11].Value = model.Issued; parameters[12].Value = model.IssuedCount; parameters[13].Value = model.ActualPrice; parameters[14].Value = model.PayTypeID; parameters[15].Value = model.TrackDescription; parameters[16].Value = model.ClientSurvey; parameters[17].Value = model.APRemark; parameters[18].Value = model.Creator; parameters[19].Value = model.Editor; parameters[20].Value = model.EditTime; parameters[21].Value = model.FirstChecker; parameters[22].Value = model.State; parameters[23].Value = model.SecondCheckerName; parameters[24].Value = model.ReaderName; parameters[25].Value = model.Qty; parameters[26].Value = model.UnitID; parameters[27].Value = model.IsTax; parameters[28].Value = model.IsShipping; parameters[29].Value = model.APID; IDbTransaction transaction = DBAccess.BeginDbTransaction(DB.Type, DB.ConnectionString); try { DBAccess.ExecuteNonQuery(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters); APSecondCheckDAL soSC = new APSecondCheckDAL(); int socount = model.SCList.Count; if (socount > 0) { soSC.Delete(model.APID); for (int i = 0; i < socount; i++) { APSecondCheck sosc = model.SCList[i] as APSecondCheck; soSC.Add(sosc); } } APReaderDAL rSC = new APReaderDAL(); int rcount = model.RList.Count; if (rcount > 0) { rSC.Delete(model.APID); for (int i = 0; i < rcount; i++) { APReader sor = model.RList[i] as APReader; rSC.Add(sor); } } transaction.Commit(); } catch { transaction.Rollback(); } return(true); }