//根据换货单号得到换货单详细 /// <summary> /// 根据换货单号得到换货单详细 /// </summary> /// <returns></returns> public void SaveReplacementlModelByDisplaceOrderID(string displaceOrderID, string number, ReplacementModel replacementModel, ArrayList displaceList) { using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { //得到制单人 CommonDataDAL commonDataDAL = new CommonDataDAL(); string makeman = commonDataDAL.GetNameByAdminID(number); //删除原来的明细 SqlParameter[] sPara = new SqlParameter[] { new SqlParameter("@num", SqlDbType.VarChar, 20) }; sPara[0].Value = displaceOrderID; DBHelper.ExecuteNonQuery(tran, "delete from ReplacementDetail where displaceOrderID =@num", sPara, CommandType.Text); foreach (ReplacementDetailModel replacementDetailModel in displaceList) { replacementDetailModel.DisplaceOrderID = replacementModel.DisplaceOrderID; } CreateReplacementDetails(tran, displaceList, displaceOrderID); //更新原来的换货单信息 string SQL_UPDATE_DisplaceGoodsOrder = @"UPDATE Replacement SET MakeDocPerson = @MakeDocPerson, ExpectNum = @ExpectNum, OutTotalMoney = @OutTotalMoney, OutTotalPV = @OutTotalPV, InTotalMoney = @InTotalMoney, InTotalPV = @InTotalPV, InceptAddress = @InceptAddress, InceptPerson = @InceptPerson, PostalCode = @PostalCode, Telephone = @Telephone,remark=@remark WHERE DisplaceOrderID = @DisplaceOrderID" ; SqlParameter[] para = { new SqlParameter("@MakeDocPerson", replacementModel.MakeDocPerson), new SqlParameter("@ExpectNum", replacementModel.ExpectNum), new SqlParameter("@OutTotalMoney", replacementModel.OutTotalMoney), new SqlParameter("@OutTotalPV", replacementModel.OutTotalPV), new SqlParameter("@InTotalMoney", replacementModel.InTotalMoney), new SqlParameter("@InTotalPV", replacementModel.InTotalPV), new SqlParameter("@InceptAddress", replacementModel.InceptAddress), new SqlParameter("@InceptPerson", replacementModel.InceptPerson), new SqlParameter("@PostalCode", replacementModel.PostalCode), new SqlParameter("@Telephone", replacementModel.Telephone), new SqlParameter("@DisplaceOrderID", replacementModel.DisplaceOrderID), new SqlParameter("@remark", replacementModel.Remark) }; int a = DBHelper.ExecuteNonQuery(tran, SQL_UPDATE_DisplaceGoodsOrder, para, CommandType.Text); tran.Commit(); } catch (Exception err) { tran.Rollback(); throw err; } finally { conn.Close(); } } }